
// Open ID
$("#google_reges").click(function(){
    var url = 'https://www.google.com/accounts/o8/id';
    OpenWindow(url);
});
$("#yahoo_reges").click(function(){
    var url = 'https://me.yahoo.com/';
    OpenWindow(url);
});
$("#facebook_reges").click(function(){
    var url = $(".url_facebook").val();
    OpenWindow(url,true);
});
$("#govn_reges").click(function(){
    var url = $(".url_govn").val();
    OpenWindow(url,true);
});

$("#google").click(function(){
    var url = 'https://www.google.com/accounts/o8/id';
    OpenWindow(url);
})
$("#yahoo").click(function(){
    var url = 'https://me.yahoo.com/';
    OpenWindow(url);
})
$("#facebook").click(function(){
    var url = $(".url_facebook").val();
    OpenWindow(url,true);
})
$("#govn").click(function(){
    var url = $(".url_govn").val();
    OpenWindow(url,true);
})

function OpenWindow(url_send,check){
    if(check == true)
        url = url_send;
    else
        url = 'openid/openid.php?url='+url_send;
    var w = screen.availWidth;
    var h = screen.availHeight;
    var left = (screen.width/2)-(w/2) + 5;
    var top = (screen.height/2)-(h/2) - 10;
    window.open(url,'facebook',' width=500, height=500, top='+top+', left='+left);
}
function finish_request(openid_args) {
    var page = $(".page_current").val();
    $.ajax({
        url: 'ajax.php?fnc=openid&path=openid&'+openid_args,
        type:'GET',       
        dataType:'json',
        success:function(data){
            if(page == 'register'){
                $('#openid_form').css('display','none');
                $('#connect_form').css('display','block');
                $(".openid").val(data.url);
                $(".fullname").val(data.name);
                $(".email").val(data.email_open);
                $(".emailopend").val(data.uid);
                $("#current").html(data.current);
                $("#logo_ajax").html(data.logo);
                $("#check_config").val('1');
            }
            else{                
                window.location.replace(data.url_reload);
            }
        }  
    });
}
function completed(){
    url = $("#url_complate").val();
    window.location.reload(url);
}
function lock(){
    jAlert('Tài khoản của bạn đang bị khóa, vui lòng liên hệ ban quản trị để được hỗ trợ','Thông báo');
    
}
function changeImageOpen()
{
	$("#verify_image_open").attr('src',$("#verify_image_open").attr('src')+'&1');
}//process taskbar
$("#text").click(function(){
   var input = $("#text").val();
   if(isNumber(input)){
	 alert("ok");
   }else
	alert("false");
   
});
function isNumber(x) 
{ 
  return ( (typeof x === typeof 1) && (null !== x) && isFinite(x) );
}

//----------------------------------------------
function getUrl(){
	var a = document.location.href;
	var _params = {};
	var paramsRaw = (a.split("?", 2)[1] || "").split('#')[0].split("&") || [];
	for(var i = 0; i < paramsRaw.length; i++){
		var param = paramsRaw[i].split("=");
		if(param[0])
			_params[param[0]] = param[1];
	}
	return _params;
}


//------------------------------------------
//get catalog
$('#account-top li.login_current, #content-aliasx, #support-html, li.support a.show-list').click(function(e) {
	e.stopPropagation(); //Prevents the subpanel ul from closing on click
});


$(document).click(function() { //Click anywhere and...
   $("#account-top li.login_current ul").slideUp(100); //hide subpanel
   $('#account-top li.login_current').children('a').removeClass('active');
   $('#account-top li.login_current').children('ul').removeClass('un_checked');
   closeSupport();
});

$(document).ready(function() {
	$("#account-top li#regeriter").hover(
		function(){
			$(this).children('a').addClass('active');
		},
		function(){
			$(this).children('a').removeClass('active');
		}
	);
	$("#account-top li.login_current").hover(
		function(){
			$(this).children('a').addClass('active');
		},
		function(){
			if($('#account-top li.login_current').children('ul').attr('class') != 'submenu-topbar formLogin un_checked')
				$(this).children('a').removeClass('active');
		}
	);
	$('#account-top li.login_current a.login-title').click(
		function(){
			$('#account-top li.login_current').children('ul').addClass('un_checked');
			$('#account-top li.login_current').children('a').addClass('active');
			$("#account-top li.login_current").children('ul').slideDown(100);
			return false;
		}
	);
	
	$('#btnSearchTaskbar').click(function(){
		
		var txtSearchTaskbar = $("#txtSearchTaskbar").val();
		//txtSearchTaskbar = str_replace(" ", "", txtSearchTaskbar);
		if(txtSearchTaskbar == ""){
			alert("Bạn phải nhập từ khóa tìm kiếm.");
		}
		
	});
	$('#show_sys_admin_menu').click(function(i) { 
		if ($(this).html() == '<span>+ Mở rộng</span>') 
			$(this).html('<span>- Thu gọn</span>');
		else 
			$(this).html('<span>+ Mở rộng</span>');
		$('.sys_admin_menu').animate({"height": "toggle"}, { duration: 200 });
	});
	
	$("#topBar li.view_more_menu").hover(
		  function(){
			if($("#content-aliasx").attr('class') != 'support_active'){
				$(this).children('a').addClass('active');
				$("#list-menu-more-store").slideDown(200);
			}
		  },
		  function(){
			if($("#content-aliasx").attr('class') != 'support_active'){
				$("#list-menu-more-store").slideUp(100);
				$(this).children('a').removeClass('active');
			}
		  }
	  );
	  $("#topBar li.view_support a").click(function(){
		$.get("support.htm",function(data){
			$("#list-menu-more-store").slideUp(100);
			$("#topBar li.view_more_menu").children('a').addClass('active');
			$("#content-aliasx").html(data);
			$("#content-aliasx").addClass('support_active');
			$("#list_data_support").css('top','30px');
			$("#list_data_support").css('left','-265px');
		});
	  });	  
	  $("#topBar li.support").hoverDelay({
		  'over': function() {
				$(this).children('a').addClass('active');
				if($("#support-html").attr('class') == 'clearfix current_view'){
					$("#list_data_support").css('display','block');
					$("#support-html").show();    
				}else{
					$.ajax({
						beforeSend: function(){
							$("#support-html").addClass('current_view');
							$("#support-html").html("Đang tải...").show();  
						},
						cache:true,
						url:"support.htm",
						type:"GET",
						success: function(data){
							$("#support-html").html(data);
						}
					});
				}
		  },
		  'out': function() {
				$(this).children('a').removeClass('active');
				$("#support-html").hide();
		  }
	  })
	  $("#topBar li.ebay_support").hoverDelay({
		  'over': function() {
				$(this).children('a').addClass('active');
				if($("#support-html").attr('class') == 'clearfix current_view'){
					$("#support-html").show();    
				}else{
					$.ajax({
						beforeSend: function(){
							$("#support-html").addClass('current_view');
							$("#support-html").html("Đang tải...").show();  
						},
						cache:true,
						url:"ebay_support.htm",
						type:"GET",
						success: function(data){
							$("#support-html").css('left','-170px');
							$("#support-html").html(data); 
						}
					});
				}              
		  }, 
		  'out': function() {
			  $(this).children('a').removeClass('active');
			  $("#support-html").hide();
		  }
	  })	 	//
//      $("ul#account-top li.hover-view").hover(
//          function(){
//            $(this).children('a').addClass('active');
//            $(".content-navigation").slideDown(200);
//          },
//          function(){
//            $(this).children('a').removeClass('active');
//            //$(".content-navigation").slideUp(200);
//          }
//      );
});
function closeSupport(){
	$("#content-aliasx").removeClass('support_active');
	$("#list_data_support").hide();
	$("#topBar li.view_more_menu").children('a').removeClass('active');
};
var delay;
$("#item-link li.browse").hover(
	function(){
		 var el = $(this);
		 clearTimeout(delay);
		 delay = setTimeout(function(){
			 el.children(".sub-support").show(); 
		 }, 200);
		 
	},
	function(){
		 clearTimeout(delay);
		 $(this).children(".sub-support").hide();
	}   
);

function getKeywordById(id_textbox)
{
	var keyword =  $("#"+id_textbox).val(); 
	keyword = keyword.replace(/([\?*#<>!\$%^&\(\)\/\\]+)/g,"");
	keyword = keyword.replace(/([ ]+)/g," ");
	keyword = keyword.replace(/\"/g, '');
	return keyword;
}

function processFocusById(id_textbox)
{       
	$("#"+id_textbox).val('');    
}
function processBlueById(id_textbox)
{    
	var keyword =  getKeywordById(id_textbox);    
	if(keyword == ''){ 
		$("#"+id_textbox).val("Nhập từ khóa tìm kiếm");
	}   
}
$('#icon_guaranteed').hover(function(){
	$('#show_icon_guaranteed').css('display','block');
}, function() {
	$('#show_icon_guaranteed').css('display','none'); 
});    
$('#icon_shop').hover(function(){
	$('#show_icon_shop').css('display','block');
}, function() {
	$('#show_icon_shop').css('display','none'); 
});  
(function($) {

$.extend($.fn, {
	livequery: function(type, fn, fn2) {
		var self = this, q;

		// Handle different call patterns
		if ($.isFunction(type))
			fn2 = fn, fn = type, type = undefined;

		// See if Live Query already exists
		$.each( $.livequery.queries, function(i, query) {
			if ( self.selector == query.selector && self.context == query.context &&
				type == query.type && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) )
					// Found the query, exit the each loop
					return (q = query) && false;
		});

		// Create new Live Query if it wasn't found
		q = q || new $.livequery(this.selector, this.context, type, fn, fn2);

		// Make sure it is running
		q.stopped = false;

		// Run it immediately for the first time
		q.run();

		// Contnue the chain
		return this;
	},

	expire: function(type, fn, fn2) {
		var self = this;

		// Handle different call patterns
		if ($.isFunction(type))
			fn2 = fn, fn = type, type = undefined;

		// Find the Live Query based on arguments and stop it
		$.each( $.livequery.queries, function(i, query) {
			if ( self.selector == query.selector && self.context == query.context &&
				(!type || type == query.type) && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) && !this.stopped )
					$.livequery.stop(query.id);
		});

		// Continue the chain
		return this;
	}
});

$.livequery = function(selector, context, type, fn, fn2) {
	this.selector = selector;
	this.context  = context;
	this.type     = type;
	this.fn       = fn;
	this.fn2      = fn2;
	this.elements = [];
	this.stopped  = false;

	// The id is the index of the Live Query in $.livequery.queries
	this.id = $.livequery.queries.push(this)-1;

	// Mark the functions for matching later on
	fn.$lqguid = fn.$lqguid || $.livequery.guid++;
	if (fn2) fn2.$lqguid = fn2.$lqguid || $.livequery.guid++;

	// Return the Live Query
	return this;
};

$.livequery.prototype = {
	stop: function() {
		var query = this;

		if ( this.type )
			// Unbind all bound events
			this.elements.unbind(this.type, this.fn);
		else if (this.fn2)
			// Call the second function for all matched elements
			this.elements.each(function(i, el) {
				query.fn2.apply(el);
			});

		// Clear out matched elements
		this.elements = [];

		// Stop the Live Query from running until restarted
		this.stopped = true;
	},

	run: function() {
		// Short-circuit if stopped
		if ( this.stopped ) return;
		var query = this;

		var oEls = this.elements,
			els  = $(this.selector, this.context),
			nEls = els.not(oEls);

		// Set elements to the latest set of matched elements
		this.elements = els;

		if (this.type) {
			// Bind events to newly matched elements
			nEls.bind(this.type, this.fn);

			// Unbind events to elements no longer matched
			if (oEls.length > 0)
				$.each(oEls, function(i, el) {
					if ( $.inArray(el, els) < 0 )
						$.event.remove(el, query.type, query.fn);
				});
		}
		else {
			// Call the first function for newly matched elements
			nEls.each(function() {
				query.fn.apply(this);
			});

			// Call the second function for elements no longer matched
			if ( this.fn2 && oEls.length > 0 )
				$.each(oEls, function(i, el) {
					if ( $.inArray(el, els) < 0 )
						query.fn2.apply(el);
				});
		}
	}
};

$.extend($.livequery, {
	guid: 0,
	queries: [],
	queue: [],
	running: false,
	timeout: null,

	checkQueue: function() {
		if ( $.livequery.running && $.livequery.queue.length ) {
			var length = $.livequery.queue.length;
			// Run each Live Query currently in the queue
			while ( length-- )
				$.livequery.queries[ $.livequery.queue.shift() ].run();
		}
	},

	pause: function() {
		// Don't run anymore Live Queries until restarted
		$.livequery.running = false;
	},

	play: function() {
		// Restart Live Queries
		$.livequery.running = true;
		// Request a run of the Live Queries
		$.livequery.run();
	},

	registerPlugin: function() {
		$.each( arguments, function(i,n) {
			// Short-circuit if the method doesn't exist
			if (!$.fn[n]) return;

			// Save a reference to the original method
			var old = $.fn[n];

			// Create a new method
			$.fn[n] = function() {
				// Call the original method
				var r = old.apply(this, arguments);

				// Request a run of the Live Queries
				$.livequery.run();

				// Return the original methods result
				return r;
			}
		});
	},

	run: function(id) {
		if (id != undefined) {
			// Put the particular Live Query in the queue if it doesn't already exist
			if ( $.inArray(id, $.livequery.queue) < 0 )
				$.livequery.queue.push( id );
		}
		else
			// Put each Live Query in the queue if it doesn't already exist
			$.each( $.livequery.queries, function(id) {
				if ( $.inArray(id, $.livequery.queue) < 0 )
					$.livequery.queue.push( id );
			});

		// Clear timeout if it already exists
		if ($.livequery.timeout) clearTimeout($.livequery.timeout);
		// Create a timeout to check the queue and actually run the Live Queries
		$.livequery.timeout = setTimeout($.livequery.checkQueue, 20);
	},

	stop: function(id) {
		if (id != undefined)
			// Stop are particular Live Query
			$.livequery.queries[ id ].stop();
		else
			// Stop all Live Queries
			$.each( $.livequery.queries, function(id) {
				$.livequery.queries[ id ].stop();
			});
	}
});

// Register core DOM manipulation methods
$.livequery.registerPlugin('append', 'prepend', 'after', 'before', 'wrap', 'attr', 'removeAttr', 'addClass', 'removeClass', 'toggleClass', 'empty', 'remove', 'html');

// Run Live Queries when the Document is ready
$(function() { $.livequery.play(); });

})(jQuery);(function($){
	
	$.extend({
			 
		anchors : function(speed, easing,urlCustom,redirect){
				
			var scrollElement = 'html, body';
			$('html, body').each(function () {
				var initScrollTop = $(this).attr('scrollTop');
				$(this).attr('scrollTop', initScrollTop + 1);
				if ($(this).attr('scrollTop') == initScrollTop + 1) {
					scrollElement = this.nodeName.toLowerCase();
					$(this).attr('scrollTop', initScrollTop);
					return false;
				}    
			});
				
			speed = speed || "fast";
			easing = easing || null;
			redirect = (redirect === true) ? true : false;
			//alert(redirect);
			
			$("a.anchor").each(function(i){
                url = urlCustom || $(this).attr("rel"); 
				if(url){
					if(url.indexOf("#") != -1 && url.indexOf("#") == 0){
		
						var aParts = url.split("#",2);
						var anchor = $("#"+aParts[1]);
						
						if(anchor){
																					
							$(this).click(function(){
												   
								if($(document).height()-anchor.offset().top >= $(window).height()
								 || anchor.offset().top > $(window).height()
								 || $(document).width()-anchor.offset().left >= $(window).width()
								 || anchor.offset().left > $(window).width()){
												   
									$(scrollElement).animate({
										scrollTop: (anchor.offset().top - 35),
										scrollLeft: anchor.offset().left
									}, speed, easing, function(){
										if(redirect){ 
											window.location = url 
										}
									});
								
								}
								
								return false;
																
							});
						}
					
					}
					
				}
				
			});
			
		}
	
	});
	
})(jQuery);
$.anchors(); 
(function($) {
	
	$.alerts = {
		
		// These properties can be read/written by accessing $.alerts.propertyName from your scripts at any time
		
		verticalOffset: -75,                // vertical offset of the dialog from center screen, in pixels
		horizontalOffset: 0,                // horizontal offset of the dialog from center screen, in pixels/
		repositionOnResize: true,           // re-centers the dialog on window resize
		overlayOpacity: .01,                // transparency level of overlay
		overlayColor: '#FFF',               // base color of overlay
		draggable: false,                    // make the dialogs draggable (requires UI Draggables plugin)
		okButton: '&nbsp;Đồng ý&nbsp;',         // text for the OK button
		cancelButton: '&nbsp;Bỏ qua&nbsp;', // text for the Cancel button
		dialogClass: null,                  // if specified, this class will be applied to all dialogs
		
		// Public methods
		
		alert: function(message, title, callback) {
			if( title == null ) title = 'Thông báo';
			$.alerts._show(title, message, null, 'alert', function(result) {
				if( callback ) callback(result);
			});
		},
		
		confirm: function(message, title, callback) {
			if( title == null ) title = 'Xác nhận';
			$.alerts._show(title, message, null, 'confirm', function(result) {
				if( callback ) callback(result);
			});
		},
			
		prompt: function(message, value, title, callback) {
			if( title == null ) title = 'Prompt';
			$.alerts._show(title, message, value, 'prompt', function(result) {
				if( callback ) callback(result);
			});
		},
		
		// Private methods
		
		_show: function(title, msg, value, type, callback) {
			
			$.alerts._hide();
			$.alerts._overlay('show');
			
			$("BODY").append(
			  '<div id="popup_container">' +
			    '<h1 id="popup_title"></h1>' +
			    '<div id="popup_content">' +
			      '<p id="popup_message"></p>' +
				'</div>' +
			  '</div>');
			
			if( $.alerts.dialogClass ) $("#popup_container").addClass($.alerts.dialogClass);
			
			// IE6 Fix
			var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ) ? 'absolute' : 'fixed'; 
			
			$("#popup_container").css({
				position: pos,
				zIndex: 99999,
				margin: 0
			});
			
			$("#popup_title").text(title);
			$("#popup_content").addClass(type);
			$("#popup_message").text(msg);
			$("#popup_message").html( $("#popup_message").text().replace(/\n/g, '<br />') );
			
			$("#popup_container").css({
				minWidth: $("#popup_container").outerWidth(),
				maxWidth: $("#popup_container").outerWidth()
			});
			
			$.alerts._reposition();
			$.alerts._maintainPosition(true);
			
			switch( type ) {
				case 'alert':
					$("#popup_message").after('<div id="popup_panel"><input class="submit-orange" type="button" value="' + $.alerts.okButton + '" id="popup_ok" /></div>');
					$("#popup_ok").click( function() {
						$.alerts._hide();
						callback(true);
					});
					$("#popup_ok").focus().keypress( function(e) {
						if( e.keyCode == 13 || e.keyCode == 27 ) $("#popup_ok").trigger('click');
					});
				break;
				case 'confirm':
					$("#popup_message").after('<div id="popup_panel"><input class="submit-orange" type="button" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" value="' + $.alerts.cancelButton + '" id="popup_cancel" class="submit-dark"/></div>');
					$("#popup_ok").click( function() {
						$.alerts._hide();
						if( callback ) callback(true);
					});
					$("#popup_cancel").click( function() {
						$.alerts._hide();
						if( callback ) callback(false);
					});
					$("#popup_ok").focus();
					$("#popup_ok, #popup_cancel").keypress( function(e) {
						if( e.keyCode == 13 ) $("#popup_ok").trigger('click');
						if( e.keyCode == 27 ) $("#popup_cancel").trigger('click');
					});
				break;
				case 'prompt':
					$("#popup_message").append('<br /><input type="text" size="30" id="popup_prompt" />').after('<div id="popup_panel"><input class="submit-orange" type="button" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" value="' + $.alerts.cancelButton + '" id="popup_cancel" class="submit-dark"/></div>');
					$("#popup_prompt").width( $("#popup_message").width() );
					$("#popup_ok").click( function() {
						var val = $("#popup_prompt").val();
						$.alerts._hide();
						if( callback ) callback( val );
					});
					$("#popup_cancel").click( function() {
						$.alerts._hide();
						if( callback ) callback( null );
					});
					$("#popup_prompt, #popup_ok, #popup_cancel").keypress( function(e) {
						if( e.keyCode == 13 ) $("#popup_ok").trigger('click');
						if( e.keyCode == 27 ) $("#popup_cancel").trigger('click');
					});
					if( value ) $("#popup_prompt").val(value);
					$("#popup_prompt").focus().select();
				break;
			}
			
			// Make draggable
			if( $.alerts.draggable ) {
				try {
					$("#popup_container").draggable({ handle: $("#popup_title") });
					$("#popup_title").css({ cursor: 'move' });
				} catch(e) { /* requires jQuery UI draggables */ }
			}
		},
		
		_hide: function() {
			$("#popup_container").remove();
			$.alerts._overlay('hide');
			$.alerts._maintainPosition(false);
		},
		
		_overlay: function(status) {
			switch( status ) {
				case 'show':
					$.alerts._overlay('hide');
					$("BODY").append('<div id="popup_overlay"></div>');
					$("#popup_overlay").css({
						position: 'absolute',
						zIndex: 99998,
						top: '0px',
						left: '0px',
						width: '100%',
						height: $(document).height(),
						background: $.alerts.overlayColor,
						opacity: $.alerts.overlayOpacity
					});
				break;
				case 'hide':
					$("#popup_overlay").remove();
				break;
			}
		},
		
		_reposition: function() {
			var top = (($(window).height() / 2) - ($("#popup_container").outerHeight() / 2)) + $.alerts.verticalOffset;
			var left = (($(window).width() / 2) - ($("#popup_container").outerWidth() / 2)) + $.alerts.horizontalOffset;
			if( top < 0 ) top = 0;
			if( left < 0 ) left = 0;
			
			// IE6 fix
			if( $.browser.msie && parseInt($.browser.version) <= 6 ) top = top + $(window).scrollTop();
			
			$("#popup_container").css({
				top: top + 'px',
				left: left + 'px'
			});
			$("#popup_overlay").height( $(document).height() );
		},
		
		_maintainPosition: function(status) {
			if( $.alerts.repositionOnResize ) {
				switch(status) {
					case true:
						$(window).bind('resize', $.alerts._reposition);
					break;
					case false:
						$(window).unbind('resize', $.alerts._reposition);
					break;
				}
			}
		}
		
	};
	
	// Shortuct functions
	jAlert = function(message, title, callback) {
		$.alerts.alert(message, title, callback);
	};
	
	jConfirm = function(message, title, callback) {
		$.alerts.confirm(message, title, callback);
	};
		
	jPrompt = function(message, value, title, callback) {
		$.alerts.prompt(message, value, title, callback);
	};
	
})(jQuery);/*
 * jGD DropDown
 * Version 0.4 (18-SEP-2010)
 * @requires jQuery v1.3 or later
 *
 * Homepage: http://www.dev4press.com/jquery/jgd-dropdown/
 * Examples: http://www.dev4press.com/jgd/dropdown/
 * 
 * Copyright (c) 2008-2010 Milan Petrovic, Dev4Press
 *
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Thanks to Janko at Warp Speed for this great article:
 * http://www.jankoatwarpspeed.com/post/2009/07/28/reinventing-drop-down-with-css-jquery.aspx
 */

(function($){
    $.fn.jgdDropdown = function(options) {
        var settings =  $.extend({}, $.fn.jgdDropdown.defaults, options);
        return this.each(function() {
            var $this = $(this);
            var $id = $.fn.jgdDropdown.convert($this, settings);

            $("#" + $id + " dt a").click(function() {
                $("#" + $id + " dd ul").toggle();
                return false;
            });

            $(document).bind('click', function(e) {
                var $clicked = $(e.target);
                if (!$clicked.parents().hasClass(settings.cls)) {
                    $("." + settings.cls + " dd ul").hide();
                }
            });

            $("#" + $id + " dd ul li a").click(function() {
                var $sel = $(this);
                var $val = $sel.find("span.value").html();
                $this.val($val);
                $("#" + $id + " dt a").html($sel.html());
                $("#" + $id + " dd ul").hide();
                if (settings.clsCopySelect) {
                    $("#" + $id + " dt").attr("class", $sel.parent().attr("class"));
                }
                $sel.parent().parent().find("li").removeClass(settings.clsLISelected);
                $sel.parent().addClass(settings.clsLISelected);
                if (settings.callback) {
                    settings.callback($this, $val);
                }
                return false;
            });
        });
    };
    $.fn.jgdDropdown.defaults = {
        callback: null,
        cls: 'jgd-dropdown',
        initTitle: '',
        forceTitle: false,
        clsLIPrefix: '',
        clsLISelected: 'selected',
        clsCopySelect: true,
        clsLIExpand: true,
        selected: ''
    };
    $.fn.jgdDropdown.convert = function($obj, settings) {
        var iTitle = settings.initTitle;
        var iVal = '';
        if (settings.selected !== null && settings.selected !== '') {
            $obj.val(settings.selected);
            if (!settings.forceTitle) {
                iTitle = '';
            }
        }
        var selected = $obj.find("option:selected");
        var options = $("option", $obj);
        var id = "jgd_dd_" + get_id($obj);
        $obj.after('<li id="' + id + '" class="' + settings.cls + '"></li>');
        if (iTitle === '') {
            iTitle = selected.text();
            iVal = selected.val();
        }
        $("#" + id).append('<dt><a href="#">' + iTitle + '<span class="value">' + iVal +  '</span></a></dt>');
        $("#" + id).append('<dd><ul></ul></dd>');
        options.each(function(index){
            var elClass = $(this).attr("class");
            var elStyle = $(this).attr("style");

            var cls = settings.clsLIPrefix + $(this).val();
            if (settings.clsLIExpand) {
                cls += " item-" + index;
                cls += " item-" + ($.fn.jgd.isEven(index) ? "even" : "odd");
                if (index === 0) {
                    cls += " item-first";
                }
                if (index == options.length - 1) {
                    cls += " item-last";
                }
                if(elClass && elClass !== '') {
                    cls+= " " + thisclass;
                }
            }
            if (settings.clsCopySelect) {
                $("#" + id + " dt").attr("class", cls);
            }
            if ($(this).val() == selected.val()) {
                cls += " " + settings.clsLISelected;
            }
            $("#" + id + " dd ul").append('<li class="' + cls + '"><a href="#">' +
                $(this).text() + '<span class="value">' + $(this).val() + '</span></a></li>');
            if (elStyle) {
                $("#" + id + " dd ul").find("li:last a").attr("style", elStyle);
            }
        });
        $obj.hide();
        return id;
    };
    $.fn.jgd = function() {};
    $.fn.jgd.isEven = function($num) {
        return ($num%2 === 0);
    };
    function get_id($obj) {
        var id = $obj.attr("id");
        if (id === "") {
            id = random_id();
        }
        return id;
    }
    function random_id() {
        var dt = new Date().getMilliseconds();
        var num = Math.random();
        var rnd = Math.round(num * 100000);
        return "jgd" + dt + rnd;
    }
    function debug($obj) {
        if (window.console && window.console.log) {
             window.console.log('jgd_dropdown: ' + $obj.size());
        }
    }
})(jQuery);

	$(".show-list").click( function(){		
		openPopup($(this));
	});				
	$(".show-tip").mouseover(function(){		
		openPopup($(this));
	});
	$(".popup-close").click(function(){			
		closePopup();
	});
	$(".close").click(function(){			
		closePopup();
	});
	
	$(".button-close").click(function(){			
		closePopup();
	});
	$(".popup-background").click(function(){
		closePopup();
	});
	
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupFlag==1){
			closePopup();
		}
	});		
	
	var popupFlag = 0;
	
	function openPopup(obj){
		if(popupFlag==0){			
			//var pos = obj.position();	
			var thisParent = obj.parent();
			//var parentTop = thisParent.offset().top;
			var parentTop = obj.position().top;
			var rel = obj.attr('rel');
			var windowWidth = $(window).width();
			var windowHeight = $(window).height();
			var divWidth = $("#"+rel).width(); 
			var divHeight = $("#"+rel).height(); 
			var left = (windowWidth - divWidth)/2;
			//var left = thisParent.offset().left + obj.width()/2 -  divWidth/2;
			if(left+divWidth > windowWidth) left = windowWidth - divWidth;
			var sp = rel.split('-');
			var name = sp[0];
			var id = sp[1];	
			//var top = parentTop + divHeight + 10;
			var top = - (divHeight)/2;
			$("#"+name+"-"+id).css({
				"position": "absolute",
				"top": (windowHeight-divHeight) / 2+getPageScroll()[1],				
				"left" : left
				//"top": pos.top,
				//"left": pos.left				
			});		
	
			$(".popup-background").css({
				"-moz-opacity": 0,
				"opacity": 0.0,
				"z-index": 10,								
				"top": 0,
				"left": 0
			});
	
			$(".popup-background").fadeIn("fast");
			
			$("#"+name+"-"+id).fadeIn("fast");
			
			popupFlag = rel;
		}
	}
	 function getPageScroll() {
		    var xScroll, yScroll;
		    if (self.pageYOffset) {
		      yScroll = self.pageYOffset;
		      xScroll = self.pageXOffset;
		    } else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
		      yScroll = document.documentElement.scrollTop;
		      xScroll = document.documentElement.scrollLeft;
		    } else if (document.body) {// all other Explorers
		      yScroll = document.body.scrollTop;
		      xScroll = document.body.scrollLeft;	
		    }
		    return new Array(xScroll,yScroll) 
		  }
	function closePopup(){
		if(popupFlag != 0){
			$(".popup-background").fadeOut("fast");
			$(".popup-choose").fadeOut("fast");
			resetForm('form-'+popupFlag);
			popupFlag = 0;
		}
	}
	
	function resetForm(id) {
		if($('#'+id).length > 0)
		{
			$('#'+id).each(function(){
		        this.reset();
			});
		}		
	}jQuery.cookie = function (key, value, options) {

    // key and value given, set cookie...
    if (arguments.length > 1 && (value === null || typeof value !== "object")) {
        options = jQuery.extend({}, options);

        if (value === null) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? String(value) : encodeURIComponent(String(value)),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};

/**
* Jquery Notification Chodientu.vn
* requied jgrowl , jCookie
* @Customize by HanVanLoi
* @created 10-04-2010
* @extends Jquery Notification
*/
(function($){
    $.notice = function(number, options) { 
        //hien thi so luong
        var num = parseInt($(options.noticeDiv).text()) + number;
        if(num>0) 
             $(options.noticeDiv).html(num).show();
	};
	
	$.notice.pview = function( product_id, options ){
        if(product_id =="undefined" || product_id==0 || product_id=="") return;
        var cookie_name = 'product_view';
        
        var cookie_time = 'time_product_view';                
                        
        var options = { path: '/', expires: 10 };
        var value  =  $.cookie(cookie_name);
        var time_value  = $.cookie(cookie_time);
        
        
        if(value !="" && value != null && value !='undefined' && time_value !=null && time_value != "" && time_value !='undefined'){
            var arr =  value.split(",");
            //if(time_value !="" && time_value != null && time_value !='undefined')
            var arr_time = time_value.split(',');
            
            if($.inArray(product_id,arr) == -1){
                if(arr.length >=5){
                  arr.pop();
                  value = product_id + "," + arr.toString();
                  arr_time.pop();
                  value_time = new Date().getTime()+"," + arr_time.toString();
                }else{
                  value =  product_id + "," + value ;
                  value_time = new Date().getTime() +"," + time_value;
                }
                // add thêm sản phẩm vào cookie
                $.cookie(cookie_name, value, options);
                // add số lượng chưa xem trên notice
                $.notice.addNumCookie('num_pview',options);
                
                //add time cookies
                $.cookie(cookie_time, value_time, options);
                
                return $.notice(1, $.extend( {}, options, { noticeDiv : "#pView"}));
            }
        }else{
            value = product_id;
            $.cookie(cookie_name, value, options);
            // add số lượng chưa xem trên notice
            $.notice.addNumCookie('num_pview',options);
            //Cookie time                                   
            $.cookie(cookie_time, new Date().getTime(), options);
                         
            return $.notice(1, $.extend( {}, options, { noticeDiv : "#pView"})); 
        }
                                                    
    };
	$.notice.pcart = function(number, options ){
        var cookie_name = 'num_pcart';
        var options = { path: '/', expires: 10 };
        // add số lượng chưa xem trên notice 
        $.notice.addNumCookie(cookie_name,options);        
        return $.notice(number, $.extend( {}, options, { noticeDiv : "#pCart"}));
    };
    // báo số trên notification
    $.notice.alert = function(number, options ){
        return $.notice(number, $.extend({}, options, { noticeDiv : "#nAlert" }));
    };
	
    $.notice.psave = function(number, options ){
        var cookie_name = 'num_psave'; 
        var options = { path: '/', expires: 10 };
        // add số lượng chưa xem trên notice 
        $.notice.addNumCookie(cookie_name,options);
        return $.notice(number, $.extend( {}, options, { noticeDiv : "#pSave" }));
    };
    
    $.notice.addNumCookie = function (cookie_name,options){
        var value  =  $.cookie(cookie_name);
        if(value !="" && value != null){
            value_pview = parseInt(value) + 1; 
            $.cookie(cookie_name, value, options);    
        }else{
             value = 1; 
             $.cookie(cookie_name, value, options);  
        }
    };
    // xoá cookie
    $.notice.resetNumCookie = function(cookie_name){
          var options = { path: '/', expires: 10 }; 
          $.cookie(cookie_name, 0,options);
    };
    $.notice.showAlert = function (content, options){   
        return $.jGrowl(content,options);  
    };

    $.notice.load = function(href,notice_id,requie,cookie_type){
        if(requie && user_id == 0) { return false;}
        $.ajax({
            beforeSend : function(){
                 //$(notice_id).children('li.img-loading').slideDown();                 
            },
           url : href,
           dataType: 'json',
           type: "GET",
           success: function(data){                
               switch(cookie_type){                   
                   case 2 :
                        $(notice_id).html(data.content).parents(".subalert").show(500);
                        $('span.num-notify').hide();
                        break;
               }
           }
        })
    };
    
    //Cookie dem so lan load page - adv
    $.notice.numLoad=function(value,options){
        var options = { path: '/', expires: 1 };            
        $.cookie('num_load', value, options);
    };
    
    $.notice.numLoadTime=function(options){
        var options = { path: '/', expires: 1 };
        $.cookie('num_load_time', new Date().getTime(), options);        
    };
    
	$.notice.defaults = {
            noticeDiv: "notice",
			effect : "fade"
        };    
})(jQuery);
if (typeof(bsn) == "undefined")
	_b = bsn = {};


if (typeof(_b.Autosuggest) == "undefined")
	_b.Autosuggest = {};
else
	alert("Autosuggest is already set!");


_b.AutoSuggest = function (id, param)
{
	// no DOM - give up!
	//
	if (!document.getElementById)
		return 0;
	
	
	
	
	// get field via DOM
	//
	this.fld = _b.DOM.gE(id);

	if (!this.fld)
		return 0;
	
	
	
	
	// init variables
	//
	this.sInp 	= "";
	this.nInpC 	= 0;
	this.aSug 	= [];
	this.iHigh 	= 0;
	
	
	
	
	// parameters object
	//
	this.oP = param ? param : {};
	
	// defaults	
	//
	var k, def = {minchars:1, meth:"get", varname:"input", className:"autosuggest", timeout:10000, delay:300, offsety:-5, shownoresults: true, noresults: "Không có từ khóa liên quan!", maxheight: 250, cache: true, maxentries: 25};
	for (k in def)
	{
		if (typeof(this.oP[k]) != typeof(def[k]))
			this.oP[k] = def[k];
	}
	
	
	// set keyup handler for field
	// and prevent autocomplete from client
	//
	var p = this;
	
	// NOTE: not using addEventListener because UpArrow fired twice in Safari
	//_b.DOM.addEvent( this.fld, 'keyup', function(ev){ return pointer.onKeyPress(ev); } );
	
	this.fld.onkeypress 	= function(ev){ return p.onKeyPress(ev); };
	this.fld.onkeyup 		= function(ev){ return p.onKeyUp(ev); };
	
	this.fld.setAttribute("autocomplete","off");
};
















_b.AutoSuggest.prototype.onKeyPress = function(ev)
{
	var key = (window.event) ? window.event.keyCode : ev.keyCode;



	// set responses to keydown events in the field
	// this allows the user to use the arrow keys to scroll through the results
	// ESCAPE clears the list
	// TAB sets the current highlighted value
	//
	var RETURN = 13;
	var TAB = 9;
	var ESC = 27;
	
	var bubble = 1;

	switch(key)
	{
		case RETURN:
			this.setHighlightedValue();
			bubble = 0;
			break;

		case ESC:
			this.clearSuggestions();
			break;
		default:
			this.getSuggestions(this.fld.value);	
	}

	return bubble;
};



_b.AutoSuggest.prototype.onKeyUp = function(ev)
{
	var key = (window.event) ? window.event.keyCode : ev.keyCode;
	


	// set responses to keydown events in the field
	// this allows the user to use the arrow keys to scroll through the results
	// ESCAPE clears the list
	// TAB sets the current highlighted value
	//

	var ARRUP = 38;
	var ARRDN = 40;
	
	var bubble = 1;

	switch(key)
	{


		case ARRUP:
			this.changeHighlight(key);
			bubble = 0;
			break;


		case ARRDN:
			this.changeHighlight(key);
			bubble = 0;
			break;
		
		
		default:
			this.getSuggestions(this.fld.value);
	}

	return bubble;
	

};








_b.AutoSuggest.prototype.getSuggestions = function (val)
{
	
	// if input stays the same, do nothing
	//
	if (val == this.sInp)
		return 0;
	
	
	// kill list
	//
	_b.DOM.remE(this.idAs);
	
	
	this.sInp = val;
	
	
	// input length is less than the min required to trigger a request
	// do nothing
	//
	if (val.length < this.oP.minchars)
	{
		this.aSug = [];
		this.nInpC = val.length;
		return 0;
	}
	
	
	
	
	var ol = this.nInpC; // old length
	this.nInpC = val.length ? val.length : 0;
	
	
	
	// if caching enabled, and user is typing (ie. length of input is increasing)
	// filter results out of aSuggestions from last request
	//
	var l = this.aSug.length;
	if (this.nInpC > ol && l && l<this.oP.maxentries && this.oP.cache)
	{
		var arr = [];
		for (var i=0;i<l;i++)
		{
			if (this.aSug[i].value.substr(0,val.length).toLowerCase() == val.toLowerCase())
				arr.push( this.aSug[i] );
		}
		this.aSug = arr;
		
		this.createList(this.aSug);
		
		
		
		return false;
	}
	else
	// do new request
	//
	{
		var pointer = this;
		var input = this.sInp;
		clearTimeout(this.ajID);
		if(input.length == 1){
			 pointer.doAjaxRequest(input)
		}
		else
			this.ajID = setTimeout( function() { pointer.doAjaxRequest(input) }, this.oP.delay );
		
	}

	return false;
};





_b.AutoSuggest.prototype.doAjaxRequest = function (input)
{
	// check that saved input is still the value of the field
	//
	
	if (input != this.fld.value)
		return false;

	var pointer = this;
	
	
	// create ajax request
	//
	if (typeof(this.oP.script) == "function")
		var url = this.oP.script(encodeURIComponent(this.sInp));
	else
		var url = this.oP.script+this.oP.varname+"="+encodeURIComponent(this.sInp);
	
	if (!url)
		return false;
	
	var meth = this.oP.meth;
	var input = this.sInp;
	
	var onSuccessFunc = function (req) { pointer.setSuggestions(req, input) };
	var onErrorFunc = function (status) { return false;};//alert("AJAX error: "+status); };

	var myAjax = new _b.Ajax();
	myAjax.makeRequest( url, meth, onSuccessFunc, onErrorFunc );
};





_b.AutoSuggest.prototype.setSuggestions = function (req, input)
{
	// if field input no longer matches what was passed to the request
	// don't show the suggestions
	//
	if (input != this.fld.value)
		return false;
	
	
	this.aSug = [];
	
	
	if (this.oP.json)
	{
		var jsondata = eval('(' + req.responseText + ')');
		
		for (var i=0;i<jsondata.results.length;i++)
		{
			this.aSug.push(  { 'id':jsondata.results[i].id, 'value':jsondata.results[i].value, 'info':jsondata.results[i].info }  );
		}
	}
	else
	{

		var xml = req.responseXML;
	
		// traverse xml
		//
		var results = xml.getElementsByTagName('results')[0].childNodes;

		for (var i=0;i<results.length;i++)
		{
			if (results[i].hasChildNodes())
				this.aSug.push(  { 'id':results[i].getAttribute('id'), 'value':results[i].childNodes[0].nodeValue, 'info':results[i].getAttribute('info') }  );
		}
	
	}
	
	this.idAs = "as_"+this.fld.id;
	

	this.createList(this.aSug);

};














_b.AutoSuggest.prototype.createList = function(arr)
{
	var pointer = this;
	
	
	
	
	// get rid of old list
	// and clear the list removal timeout
	//
	_b.DOM.remE(this.idAs);
	this.killTimeout();
	
	
	// if no results, and shownoresults is false, do nothing
	//
	if (arr.length == 0 && !this.oP.shownoresults)
		return false;
	
	
	// create holding div
	//
	var div = _b.DOM.cE("div", {id:this.idAs, className:this.oP.className});	
	
	var hcorner = _b.DOM.cE("div", {className:"as_corner"});
	var hbar = _b.DOM.cE("div", {className:"as_bar"});
	var header = _b.DOM.cE("div", {className:"as_header"});
	header.appendChild(hcorner);
	header.appendChild(hbar);
	div.appendChild(header);
	
	
	
	
	// create and populate ul
	//
	var ul = _b.DOM.cE("ul", {id:"as_ul"});
	
	
	
	
	// loop throught arr of suggestions
	// creating an LI element for each suggestion
	//
	for (var i=0;i<arr.length;i++)
	{
		// format output with the input enclosed in a EM element
		// (as HTML, not DOM)
		//
		var val = arr[i].value;
		var st = val.toLowerCase().indexOf( this.sInp.toLowerCase() );
		var output = val.substring(0,st) + "<em>" + val.substring(st, st+this.sInp.length) + "</em>" + val.substring(st+this.sInp.length);
		
		
		var span 		= _b.DOM.cE("span", {}, output, true);
		if (arr[i].info != "")
		{
			/*var br			= _b.DOM.cE("br", {});
			span.appendChild(br);*/ 
			var small		= _b.DOM.cE("small", {}, arr[i].info);
			span.appendChild(small);
		}
		
		var a 			= _b.DOM.cE("a", { href:"#" });
		
		var tl 		= _b.DOM.cE("span", {className:"tl"}, " ");
		var tr 		= _b.DOM.cE("span", {className:"tr"}, " ");
		a.appendChild(tl);
		a.appendChild(tr);  
		
		a.appendChild(span);
		
		a.name = i+1;
		a.onclick = function () { pointer.setHighlightedValue(); return false; };
		a.onmouseover = function () { pointer.setHighlight(this.name); };
		
		var li = _b.DOM.cE(  "li", {}, a  );
		
		ul.appendChild( li );
	}
	
	
	// no results
	//
	if (arr.length == 0 && this.oP.shownoresults)
	{
		var li = _b.DOM.cE(  "li", {className:"as_warning"}, this.oP.noresults  );
		ul.appendChild( li );
	}
	
	
	div.appendChild( ul );
	
	
	var fcorner = _b.DOM.cE("div", {className:"as_corner"});
	var fbar = _b.DOM.cE("div", {className:"as_bar"});
	var footer = _b.DOM.cE("div", {className:"as_footer"});
	footer.appendChild(fcorner);
	footer.appendChild(fbar);
	div.appendChild(footer);
	
	
	
	// get position of target textfield
	// position holding div below it
	// set width of holding div to width of field
	//
	var pos = _b.DOM.getPos(this.fld);
	
	div.style.left 		= pos.x + "px";
	div.style.top 		= ( pos.y + this.fld.offsetHeight + this.oP.offsety + 5) + "px";
	div.style.width 	= this.fld.offsetWidth + 143 + "px";
	
	
	
	// set mouseover functions for div
	// when mouse pointer leaves div, set a timeout to remove the list after an interval
	// when mouse enters div, kill the timeout so the list won't be removed
	//
	div.onmouseover 	= function(){ pointer.killTimeout() };
	div.onmouseout 		= function(){ pointer.resetTimeout() };


	// add DIV to document
	//
	document.getElementsByTagName("body")[0].appendChild(div);
	
	
	
	// currently no item is highlighted
	//
	this.iHigh = 0;
	
	
	
	
	
	
	// remove list after an interval
	//
	var pointer = this;
	this.toID = setTimeout(function () { pointer.clearSuggestions() }, this.oP.timeout);
};















_b.AutoSuggest.prototype.changeHighlight = function(key)
{	
	var list = _b.DOM.gE("as_ul");
	if (!list)
		return false;
	
	var n;

	if (key == 40)
		n = this.iHigh + 1;
	else if (key == 38)
		n = this.iHigh - 1;
	
	
	if (n > list.childNodes.length)
		n = list.childNodes.length;
	if (n < 1)
		n = 1;
	
	
	this.setHighlight(n);
};



_b.AutoSuggest.prototype.setHighlight = function(n)
{
	var list = _b.DOM.gE("as_ul");
	if (!list)
		return false;
	
	if (this.iHigh > 0)
		this.clearHighlight();
	
	this.iHigh = Number(n);
	
	list.childNodes[this.iHigh-1].className = "as_highlight";


	this.killTimeout();
};


_b.AutoSuggest.prototype.clearHighlight = function()
{
	var list = _b.DOM.gE("as_ul");
	if (!list)
		return false;
	
	if (this.iHigh > 0)
	{
		list.childNodes[this.iHigh-1].className = "";
		this.iHigh = 0;
	}
};


_b.AutoSuggest.prototype.setHighlightedValue = function ()
{
	if (this.iHigh)
	{
		this.sInp = this.fld.value = this.aSug[ this.iHigh-1 ].value;
		
		// move cursor to end of input (safari)
		//
		this.fld.focus();
		if (this.fld.selectionStart)
			this.fld.setSelectionRange(this.sInp.length, this.sInp.length);
		

		this.clearSuggestions();
		
		// pass selected object to callback function, if exists
		//
		if (typeof(this.oP.callback) == "function")
			this.oP.callback( this.aSug[this.iHigh-1] );
	}
};













_b.AutoSuggest.prototype.killTimeout = function()
{
	clearTimeout(this.toID);
};

_b.AutoSuggest.prototype.resetTimeout = function()
{
	clearTimeout(this.toID);
	var pointer = this;
	this.toID = setTimeout(function () { pointer.clearSuggestions() }, 1000);
};







_b.AutoSuggest.prototype.clearSuggestions = function ()
{
	
	this.killTimeout();
	
	var ele = _b.DOM.gE(this.idAs);
	var pointer = this;
	if (ele)
	{
		var fade = new _b.Fader(ele,1,0,250,function () { _b.DOM.remE(pointer.idAs) });
	}
};










// AJAX PROTOTYPE _____________________________________________


if (typeof(_b.Ajax) == "undefined")
	_b.Ajax = {};



_b.Ajax = function ()
{
	this.req = {};
	this.isIE = false;
};



_b.Ajax.prototype.makeRequest = function (url, meth, onComp, onErr)
{
	
	if (meth != "POST")
		meth = "GET";
	
	this.onComplete = onComp;
	this.onError = onErr;
	
	var pointer = this;
	
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest)
	{
		this.req = new XMLHttpRequest();
		this.req.onreadystatechange = function () { pointer.processReqChange() };
		this.req.open("GET", url, true); //
		this.req.send(null);
	// branch for IE/Windows ActiveX version
	}
	else if (window.ActiveXObject)
	{
		this.req = new ActiveXObject("Microsoft.XMLHTTP");
		if (this.req)
		{
			this.req.onreadystatechange = function () { pointer.processReqChange() };
			this.req.open(meth, url, true);
			this.req.send();
		}
	}
};


_b.Ajax.prototype.processReqChange = function()
{
	
	// only if req shows "loaded"
	if (this.req.readyState == 4) {
		// only if "OK"
		if (this.req.status == 200)
		{
			this.onComplete( this.req );
		} else {
			this.onError( this.req.status );
		}
	}
};










// DOM PROTOTYPE _____________________________________________


if (typeof(_b.DOM) == "undefined")
	_b.DOM = {};



/* create element */
_b.DOM.cE = function ( type, attr, cont, html )
{
	var ne = document.createElement( type );
	if (!ne)
		return 0;
		
	for (var a in attr)
		ne[a] = attr[a];
	
	var t = typeof(cont);
	
	if (t == "string" && !html)
		ne.appendChild( document.createTextNode(cont) );
	else if (t == "string" && html)
		ne.innerHTML = cont;
	else if (t == "object")
		ne.appendChild( cont );

	return ne;
};



/* get element */
_b.DOM.gE = function ( e )
{
	var t=typeof(e);
	if (t == "undefined")
		return 0;
	else if (t == "string")
	{
		var re = document.getElementById( e );
		if (!re)
			return 0;
		else if (typeof(re.appendChild) != "undefined" )
			return re;
		else
			return 0;
	}
	else if (typeof(e.appendChild) != "undefined")
		return e;
	else
		return 0;
};



/* remove element */
_b.DOM.remE = function ( ele )
{
	var e = this.gE(ele);
	
	if (!e)
		return 0;
	else if (e.parentNode.removeChild(e))
		return true;
	else
		return 0;
};



/* get position */
_b.DOM.getPos = function ( e )
{
	var e = this.gE(e);

	var obj = e;

	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	
	var obj = e;
	
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;

	return {x:curleft, y:curtop};
};










// FADER PROTOTYPE _____________________________________________



if (typeof(_b.Fader) == "undefined")
	_b.Fader = {};





_b.Fader = function (ele, from, to, fadetime, callback)
{	
	if (!ele)
		return 0;
	
	this.e = ele;
	
	this.from = from;
	this.to = to;
	
	this.cb = callback;
	
	this.nDur = fadetime;
		
	this.nInt = 50;
	this.nTime = 0;
	
	var p = this;
	this.nID = setInterval(function() { p._fade() }, this.nInt);
};




_b.Fader.prototype._fade = function()
{
	this.nTime += this.nInt;
	
	var ieop = Math.round( this._tween(this.nTime, this.from, this.to, this.nDur) * 100 );
	var op = ieop / 100;
	
	if (this.e.filters) // internet explorer
	{
		try
		{
			this.e.filters.item("DXImageTransform.Microsoft.Alpha").opacity = ieop;
		} catch (e) { 
			// If it is not set initially, the browser will throw an error.  This will set it if it is not set yet.
			this.e.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity='+ieop+')';
		}
	}
	else // other browsers
	{
		this.e.style.opacity = op;
	}
	
	
	if (this.nTime == this.nDur)
	{
		clearInterval( this.nID );
		if (this.cb != undefined)
			this.cb();
	}
};



_b.Fader.prototype._tween = function(t,b,c,d)
{
	return b + ( (c-b) * (t/d) );
};/*
 *
 * Copyright (c) 2006/2007 Sam Collett (http://www.texotela.co.uk)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * Version 2.0
 * Demo: http://www.texotela.co.uk/code/jquery/newsticker/
 *
 * $LastChangedDate: 2007-05-29 11:31:36 +0100 (Tue, 29 May 2007) $
 * $Rev: 2005 $
 *
 */
 
(function($) {
/*
 * A basic news ticker.
 *
 * @name     newsticker (or newsTicker)
 * @param    delay      Delay (in milliseconds) between iterations. Default 4 seconds (4000ms)
 * @author   Sam Collett (http://www.texotela.co.uk)
 * @example  $("#news").newsticker(); // or $("#news").newsTicker(5000);
 *
 */
$.fn.newsTicker = $.fn.newsticker = function(delay)
{
	delay = delay || 5000;
	initTicker = function(el)
	{
		stopTicker(el);
		el.items = $("li", el);
		// hide all items (except first one)
		el.items.not(":eq(0)").hide().end();
		// current item
		el.currentitem = 0;
		startTicker(el);
	};
	startTicker = function(el)
	{
		el.tickfn = setInterval(function() { doTick(el) }, delay)
	};
	stopTicker = function(el)
	{
		clearInterval(el.tickfn);
	};
	pauseTicker = function(el)
	{
		el.pause = true;
	};
	resumeTicker = function(el)
	{
		el.pause = false;
	};
	doTick = function(el)
	{
		// don't run if paused
		if(el.pause) return;
		// pause until animation has finished
		el.pause = true;
		// hide current item
		$(el.items[el.currentitem]).fadeOut("slow",
			function()
			{
				$(this).hide();
				// move to next item and show
				el.currentitem = ++el.currentitem % (el.items.size());
				$(el.items[el.currentitem]).fadeIn("slow",
					function()
					{
						el.pause = false;
					}
				);
			}
		);
	};
	this.each(
		function()
		{
			if(this.nodeName.toLowerCase()!= "ul") return;
			initTicker(this);
		}
	)
	.addClass("newsticker")
	.hover(
		function()
		{
			// pause if hovered over
			pauseTicker(this);
		},
		function()
		{
			// resume when not hovered over
			resumeTicker(this);
		}
	);
	return this;
};

})(jQuery);
function changeTabSearch(value)
{
	$("#search"+typeSearch).removeClass('active');
	$("#search"+value).addClass('active');
	var j = 0;
	var tab = new Array("Nhập từ khóa, tìm gì cũng thấy...","Nhập từ khóa để tìm rao vặt...", "Nhập từ khóa để đọc tin...","Nhập ID sản phẩm hoặc từ khóa ..."); 
	for(i=0; i<=3; i++){
		j = i+1;
		if(value==j){
			$("#tab"+j).show();
			if(jQuery.inArray($("#keywordItem").val(), tab) != -1)
				$("#keywordItem").val(tab[i]);
		}	
		else
			$("#tab"+j).hide();
			
	}
	typeSearch = value;
	$("#type_search").val(typeSearch);
}


function getKeyword()
{
	var keyword = $("#keywordItem").val(); 
	keyword = keyword.replace(/([\?*#<>!\$%^&\(\)\/\\]+)/g,"");
	keyword = keyword.replace(/([ ]+)/g," ");
	keyword = keyword.replace(/\"/g, '');
	return keyword;
}

$(document).ready(function(){   
	var options_xml = {
		script: function (input) {if(input.length >=1) {return "ajax.php?path=top_search&fnc=sugg_search_keyword&input="+input+"&testid=20";} else return false; },
		varname:"input",
		minchars: 3
	};
	var as_xml = new bsn.AutoSuggest('keywordItem', options_xml);   
});
function processFocus()
{
	var keyword = getKeyword();
	if(keyword == 'Nhập từ khóa, hoặc ID tìm kiếm...' || keyword == 'Nhập từ khóa để đọc tin...' || keyword == 'Nhập từ khóa để tìm rao vặt...' || keyword == 'Nhập ID sản phẩm hoặc từ khóa tìm kiếm...'){
		$("#keywordItem").val('');
	}
}

function processBlue()
{
	var keyword = getKeyword();
	if(keyword == ''){
		$("#keywordItem").val("Nhập từ khóa, hoặc ID tìm kiếm...");
	}
}

function ObjOnFocus(field,strMess) {
    if(field.value==strMess) {
	    field.value = '';
	    field.className = "txt_focus";
    }
}
function ObjOnBlur(field,strMess) {
    if(field.value=='')
    {
	    field.value= strMess;
	    field.className = "txt_empty";
    }
}

$(document).ready(function() {
	$("#newsflash").newsticker();    
});


(function($) {
  $.cluetip = {version: '1.1pre'};
  var $cluetip, $cluetipInner, $cluetipOuter, $cluetipTitle, $cluetipArrows, $cluetipWait, $dropShadow, imgCount;
  var insertionType = 'appendTo', insertionElement = 'body';


  $.fn.cluetip = function(js, options) {
    if (typeof js == 'object') {
      options = js;
      js = null;
    }
    if (js == 'destroy') {
      return this.removeData('cluetip').unbind('.cluetip');
    }

    // merge per-call options with defaults
    options = $.extend(true, {}, $.fn.cluetip.defaults, options || {});

    /** =create cluetip divs **/

    if (!$('#cluetip').length) {
      $(['<div id="cluetip">',
        '<div id="cluetip-outer">',
          '<h3 id="cluetip-title"></h3>',
          '<div id="cluetip-inner"></div>',
        '</div>',
        '<div id="cluetip-extra"></div>',
        '<div id="cluetip-arrows" class="cluetip-arrows"></div>',
      '</div>'].join(''))
      [insertionType](insertionElement).hide();

      var cluezIndex = +options.cluezIndex;

      $cluetip = $('#cluetip').css({position: 'absolute'});
      $cluetipOuter = $('#cluetip-outer').css({position: 'relative', zIndex: cluezIndex});
      $cluetipInner = $('#cluetip-inner');
      $cluetipTitle = $('#cluetip-title');
      $cluetipArrows = $('#cluetip-arrows');
      $cluetipWait = $('<div id="cluetip-waitimage"></div>')
        .css({position: 'absolute'}).insertBefore($cluetip).hide();
    }
    var cluetipPadding = (parseInt($cluetip.css('paddingLeft'),10)||0) + (parseInt($cluetip.css('paddingRight'),10)||0);


    this.each(function(index) {
      var link = this, $this = $(this);
     

      // support metadata plugin (v1.0 and 2.0)
      var opts = $.extend(true, {}, options, $.metadata ? $this.metadata() : $.meta ? $this.data() : {});
     

      // start out with no contents (for ajax activation)
      var cluetipContents = false;

      cluezIndex = +opts.cluezIndex;
      $this.data('cluetip', {title: link.title, zIndex: cluezIndex});
      var isActive = false, closeOnDelay = 0;

      var tipAttribute = $this.attr(opts.attribute), ctClass = opts.cluetipClass;
      if (!tipAttribute && !opts.splitTitle && !js) {
        return true;
      }
      // if hideLocal is set to true, on DOM ready hide the local content that will be displayed in the clueTip
      if (opts.local && opts.localPrefix) {tipAttribute = opts.localPrefix + tipAttribute;}
      if (opts.local && opts.hideLocal) { $(tipAttribute + ':first').hide(); }
      var tOffset = parseInt(opts.topOffset, 10), lOffset = parseInt(opts.leftOffset, 10);
      // vertical measurement variables
      var tipHeight, wHeight,
          defHeight = isNaN(parseInt(opts.height, 10)) ? 'auto' : (/\D/g).test(opts.height) ? opts.height : opts.height + 'px';
      var sTop, linkTop, posY, tipY, mouseY, baseline;
      // horizontal measurement variables
      var tipInnerWidth = parseInt(opts.width, 10) || 275,
          tipWidth = tipInnerWidth + cluetipPadding + opts.dropShadowSteps,
          linkWidth = this.offsetWidth,
          linkLeft, posX, tipX, mouseX, winWidth;

      // parse the title
      var tipParts;
      var tipTitle = (opts.attribute != 'title') ? $this.attr(opts.titleAttribute) : '';
      if (opts.splitTitle) {
        if (tipTitle == undefined) {tipTitle = '';}
        tipParts = tipTitle.split(opts.splitTitle);
        tipTitle = tipParts.shift();
      }
      if (opts.escapeTitle) {
        tipTitle = tipTitle.replace(/&/g,'&amp;').replace(/>/g,'&gt;').replace(/</g,'&lt;');
      }
      if(tipTitle=='' && opts.pathAjax!='')
    	  	tipTitle="Sản phẩm ChợĐiệnTử & Ebay";
      var localContent;
      function returnFalse() { return false; }
/***************************************
* ACTIVATION
****************************************/

//activate clueTip
    var activate = function(event) {
      if (!opts.onActivate($this)) {
        return false;
      }
      isActive = true;
      $cluetip.removeClass().css({width: tipInnerWidth});
      if (tipAttribute == $this.attr('href')) {
        $this.css('cursor', opts.cursor);
      }
      if (opts.hoverClass) {
        $this.addClass(opts.hoverClass);
      }
      linkTop = posY = $this.offset().top;
      linkLeft = $this.offset().left;
      mouseX = event.pageX;
      mouseY = event.pageY;
      if (link.tagName.toLowerCase() != 'area') {
        sTop = $(document).scrollTop();
        winWidth = $(window).width();
      }
// position clueTip horizontally
      if (opts.positionBy == 'fixed') {
        posX = linkWidth + linkLeft + lOffset;
        $cluetip.css({left: posX});
      } else {
        posX = (linkWidth > linkLeft && linkLeft > tipWidth)
          || linkLeft + linkWidth + tipWidth + lOffset > winWidth
          ? linkLeft - tipWidth - lOffset
          : linkWidth + linkLeft + lOffset;
        if (link.tagName.toLowerCase() == 'area' || opts.positionBy == 'mouse' || linkWidth + tipWidth > winWidth) { // position by mouse
          if (mouseX + 20 + tipWidth > winWidth) {
            $cluetip.addClass(' cluetip-' + ctClass);
            posX = (mouseX - tipWidth - lOffset) >= 0 ? mouseX - tipWidth - lOffset - parseInt($cluetip.css('marginLeft'),10) + parseInt($cluetipInner.css('marginRight'),10) :  mouseX - (tipWidth/2);
          } else {
            posX = mouseX + lOffset;
          }
        }
        var pY = posX < 0 ? event.pageY + tOffset : event.pageY;
        $cluetip.css({
          left: (posX > 0 && opts.positionBy != 'bottomTop') ? posX : (mouseX + (tipWidth/2) > winWidth) ? winWidth/2 - tipWidth/2 : Math.max(mouseX - (tipWidth/2),0),
          zIndex: $this.data('cluetip').zIndex
        });
        $cluetipArrows.css({zIndex: $this.data('cluetip').zIndex+1});
      }
        wHeight = $(window).height();

/***************************************
* load a string from cluetip method's first argument
***************************************/
      if (js) {
        if (typeof js == 'function') {
          js = js.call(link);
        }
        $cluetipInner.html(js);
        cluetipShow(pY);
      }
/***************************************
* load the title attribute only (or user-selected attribute).
* clueTip title is the string before the first delimiter
* subsequent delimiters place clueTip body text on separate lines
***************************************/

      else if (tipParts) {
        var tpl = tipParts.length;
        $cluetipInner.html(tpl ? tipParts[0] : '');
        if (tpl > 1) {
          for (var i=1; i < tpl; i++){
            $cluetipInner.append('<div class="split-body">' + tipParts[i] + '</div>');
          }
        }
        cluetipShow(pY);
      }
/***************************************
* load external file via ajax
***************************************/

      else if (!opts.local && tipAttribute.indexOf('#') !== 0) {
        if (/\.(jpe?g|tiff?|gif|png)$/i.test(tipAttribute)) {
          $cluetipInner.html('<img src="' + tipAttribute + '" alt="' + tipTitle + '" />');
          cluetipShow(pY);
        } else if (cluetipContents && opts.ajaxCache) {
          $cluetipInner.html(cluetipContents);
          cluetipShow(pY);
        } else {
          var optionBeforeSend = opts.ajaxSettings.beforeSend,
              optionError = opts.ajaxSettings.error,
              optionSuccess = opts.ajaxSettings.success,
              optionComplete = opts.ajaxSettings.complete;
          if(opts.pathAjax !=""){
        	   var url=link;
        	   url=String(url).replace(/\&/g ,'[||]');
        	   tipAttribute = opts.pathAjax+url;
          }
          var ajaxSettings = {
            cache: false, // force requested page not to be cached by browser
            url: tipAttribute,
            beforeSend: function(xhr) {
              if (optionBeforeSend) {optionBeforeSend.call(link, xhr, $cluetip, $cluetipInner);}
              $cluetipOuter.children().empty();
              if (opts.waitImage) {
                $cluetipWait
                .css({top: mouseY+20, left: mouseX+20, zIndex: $this.data('cluetip').zIndex-1})
                .show();
              }
            },
            error: function(xhr, textStatus) {
              if (isActive) {
                if (optionError) {
                  optionError.call(link, xhr, textStatus, $cluetip, $cluetipInner);
                } else {
                  $cluetipInner.html('<i>sorry, the contents could not be loaded</i>');
                }
              }
            },
            success: function(data, textStatus) {
              cluetipContents = opts.ajaxProcess.call(link, data);
              if (isActive) {
                if (optionSuccess) {optionSuccess.call(link, data, textStatus, $cluetip, $cluetipInner);}
                $cluetipInner.html(cluetipContents);
              }
            },
            complete: function(xhr, textStatus) {
              if (optionComplete) {optionComplete.call(link, xhr, textStatus, $cluetip, $cluetipInner);}
              var imgs = $cluetipInner[0].getElementsByTagName('img');
              imgCount = imgs.length;
              for (var i=0, l = imgs.length; i < l; i++) {
                if (imgs[i].complete) {
                  imgCount--;
                }
              }
              if (imgCount && !$.browser.opera) {
                $(imgs).bind('load error', function() {
                  imgCount--;
                  if (imgCount<1) {
                    $cluetipWait.hide();
                    if (isActive) { cluetipShow(pY); }
                  }
                });
              } else {
                $cluetipWait.hide();
                if (isActive) { cluetipShow(pY); }
              }
            }
          };
          var ajaxMergedSettings = $.extend(true, {}, opts.ajaxSettings, ajaxSettings);

          $.ajax(ajaxMergedSettings);
        }

/***************************************
* load an element from the same page
***************************************/
      } else if (opts.local) {

        var $localContent = $(tipAttribute + (/#\S+$/.test(tipAttribute) ? '' : ':eq(' + index + ')')).clone(true).show();
        if (opts.localIdSuffix) {
          $localContent.attr('id', $localContent[0].id + opts.localIdSuffix);
        }
        $cluetipInner.html($localContent);
        cluetipShow(pY);
      }
    };

// get dimensions and options for cluetip and prepare it to be shown
    var cluetipShow = function(bpY) {
      $cluetip.addClass('cluetip-' + ctClass);
      if (opts.truncate) {
        var $truncloaded = $cluetipInner.text().slice(0,opts.truncate) + '...';
        $cluetipInner.html($truncloaded);
      }

      function doNothing() {}; //empty function
      tipTitle ? $cluetipTitle.show().html(tipTitle) : (opts.showTitle) ? $cluetipTitle.show().html('&nbsp;') : $cluetipTitle.hide();
      if (opts.sticky) {
        var $closeLink = $('<div id="cluetip-close"><a href="#">' + opts.closeText + '</a></div>');
        (opts.closePosition == 'bottom') ? $closeLink.appendTo($cluetipInner) : (opts.closePosition == 'title') ? $closeLink.prependTo($cluetipTitle) : $closeLink.prependTo($cluetipInner);
        $closeLink.bind('click.cluetip', function() {
          cluetipClose();
          return false;
        });
        if (opts.mouseOutClose) {
          $cluetip.bind('mouseleave.cluetip', function() {
            cluetipClose();
          });
        } else {
          $cluetip.unbind('mouseleave.cluetip');
        }
      }
// now that content is loaded, finish the positioning
      var direction = '';
      $cluetipOuter.css({zIndex: $this.data('cluetip').zIndex, overflow: defHeight == 'auto' ? 'visible' : 'auto', height: defHeight});
      tipHeight = defHeight == 'auto' ? Math.max($cluetip.outerHeight(),$cluetip.height()) : parseInt(defHeight,10);
      tipY = posY;
      baseline = sTop + wHeight;
      if (opts.positionBy == 'fixed') {
        tipY = posY - opts.dropShadowSteps + tOffset;
      } else if ( (posX < mouseX && Math.max(posX, 0) + tipWidth > mouseX) || opts.positionBy == 'bottomTop') {
        if (posY + tipHeight + tOffset > baseline && mouseY - sTop > tipHeight + tOffset) {
          tipY = mouseY - tipHeight - tOffset;
          direction = 'top';
        } else {
          tipY = mouseY + tOffset;
          direction = 'bottom';
        }
      } else if ( posY + tipHeight + tOffset > baseline ) {
        tipY = (tipHeight >= wHeight) ? sTop : baseline - tipHeight - tOffset;
      } else if ($this.css('display') == 'block' || link.tagName.toLowerCase() == 'area' || opts.positionBy == "mouse") {
        tipY = bpY - tOffset;
      } else {
        tipY = posY - opts.dropShadowSteps;
      }
      if (direction == '') {
        posX < linkLeft ? direction = 'left' : direction = 'right';
      }
      $cluetip.css({top: tipY + 'px'}).removeClass().addClass('clue-' + direction + '-' + ctClass).addClass(' cluetip-' + ctClass);
      if (opts.arrows) { // set up arrow positioning to align with element
        var bgY = (posY - tipY - opts.dropShadowSteps);
        $cluetipArrows.css({top: (/(left|right)/.test(direction) && posX >=0 && bgY > 0) ? bgY + 'px' : /(left|right)/.test(direction) ? 0 : ''}).show();
      } else {
        $cluetipArrows.hide();
      }

// (first hide, then) ***SHOW THE CLUETIP***
      // handle dropshadow divs first
      $dropShadow = createDropShadows(opts);
      if ($dropShadow && $dropShadow.length) {
        $dropShadow.hide().css({height: tipHeight, width: tipInnerWidth, zIndex: $this.data('cluetip').zIndex-1}).show();
      }

      $cluetip.hide()[opts.fx.open](opts.fx.openSpeed || 0);
      if ($.fn.bgiframe) { $cluetip.bgiframe(); }
      // delayed close (not fully tested)
      if (opts.delayedClose > 0) {
        closeOnDelay = setTimeout(cluetipClose, opts.delayedClose);
      }
      // trigger the optional onShow function
      opts.onShow.call(link, $cluetip, $cluetipInner);
    };

/***************************************
   =INACTIVATION
-------------------------------------- */
    var inactivate = function(event) {
      isActive = false;
      $cluetipWait.hide();
      if (!opts.sticky || (/click|toggle/).test(opts.activation) ) {
        cluetipClose();
        clearTimeout(closeOnDelay);
      }
      if (opts.hoverClass) {
        $this.removeClass(opts.hoverClass);
      }
    };
// close cluetip and reset some things
    var cluetipClose = function() {
      $cluetipOuter
      .parent().hide().removeClass();
      opts.onHide.call(link, $cluetip, $cluetipInner);
      $this.removeClass('cluetip-clicked');
      if (tipTitle) {
        $this.attr(opts.titleAttribute, tipTitle);
      }
      $this.css('cursor','');
      if (opts.arrows) {
        $cluetipArrows.css({top: ''});
      }
    };

    $(document).bind('hideCluetip', function(e) {
      cluetipClose();
    });
/***************************************
   =BIND EVENTS
-------------------------------------- */
  // activate by click
      if ( (/click|toggle/).test(opts.activation) ) {
        $this.bind('click.cluetip', function(event) {
          if ($cluetip.is(':hidden') || !$this.is('.cluetip-clicked')) {
            activate(event);
            $('.cluetip-clicked').removeClass('cluetip-clicked');
            $this.addClass('cluetip-clicked');
          } else {
            inactivate(event);
          }
          this.blur();
          return false;
        });
  // activate by focus; inactivate by blur
      } else if (opts.activation == 'focus') {
        $this.bind('focus.cluetip', function(event) {
          activate(event);
        });
        $this.bind('blur.cluetip', function(event) {
          inactivate(event);
        });
  // activate by hover
      } else {
        // clicking is returned false if clickThrough option is set to false
        $this[opts.clickThrough ? 'unbind' : 'bind']('click', returnFalse);
        //set up mouse tracking
        var mouseTracks = function(evt) {
          if (opts.tracking == true) {
            var trackX = posX - evt.pageX;
            var trackY = tipY ? tipY - evt.pageY : posY - evt.pageY;
            $this.bind('mousemove.cluetip', function(evt) {
              $cluetip.css({left: evt.pageX + trackX, top: evt.pageY + trackY });
            });
          }
        };
        if ($.fn.hoverIntent && opts.hoverIntent) {
          $this.hoverIntent({
            sensitivity: opts.hoverIntent.sensitivity,
            interval: opts.hoverIntent.interval,
            over: function(event) {
              activate(event);
              mouseTracks(event);
            },
            timeout: opts.hoverIntent.timeout,
            out: function(event) {inactivate(event); $this.unbind('mousemove.cluetip');}
          });
        } else {
          $this.bind('mouseenter.cluetip', function(event) {
            activate(event);
            mouseTracks(event);
          })
          .bind('mouseleave.cluetip', function(event) {
            inactivate(event);
            $this.unbind('mousemove.cluetip');
          });
        }

        $this.bind('mouseover.cluetip', function(event) {
          $this.attr('title','');
        }).bind('mouseleave.cluetip', function(event) {
          $this.attr('title', $this.data('cluetip').title);
        });
      }
    });

    /** =private functions
    ************************************************************/
    /** =create dropshadow divs **/

    function createDropShadows(options, newDropShadow) {
      var dropShadowSteps = (options.dropShadow && options.dropShadowSteps) ? +options.dropShadowSteps : 0;
      if ($.support.boxShadow) {
        var dsOffsets = dropShadowSteps === 0 ? '0 0 ' : '1px 1px ';
       // $('#cluetip').css($.support.boxShadow, dsOffsets + dropShadowSteps + 'px rgba(0,0,0,0.5)');
	   $('#cluetip').css($.support.boxShadow, dsOffsets + dropShadowSteps + 'px #ccc');
        return false;
      }
      var oldDropShadow = $('#cluetip .cluetip-drop-shadow');
      if (dropShadowSteps == oldDropShadow.length) {
        return oldDropShadow;
      }
      oldDropShadow.remove();
      var dropShadows = [];
      for (var i=0; i < dropShadowSteps;) {
        dropShadows[i++] = '<div style="top:' + i + 'px;left:' + i + 'px;"></div>';
      }

      newDropShadow = $(dropShadows.join(''))
      .css({
        position: 'absolute',
        backgroundColor: '#000',
        zIndex: cluezIndex -1,
        opacity: .1
      })
      .addClass('cluetip-drop-shadow')
      .prependTo('#cluetip');
      return newDropShadow;

    }


    return this;
  };

  (function() {
    $.support = $.support || {};
    // check support for CSS3 properties (currently only boxShadow)
    var div = document.createElement('div'),
        divStyle = div.style,
        styleProps = ['boxShadow'],
		prefixes = ['moz', 'Moz', 'webkit', 'o'];

    for (var i=0, sl = styleProps.length; i < sl; i++) {
      var prop = styleProps[i],
          uProp = prop.charAt(0).toUpperCase() + prop.slice(1);

      if ( typeof divStyle[ prop ] !== 'undefined' ) {
        $.support[ prop ] = prop;
      } else {
        for (var j=0, pl = prefixes.length; j < pl; j++) {

          if (typeof divStyle[ prefixes[j] + uProp ] !== 'undefined') {
            $.support[ prop ] = prefixes[j] + uProp;
            break;
          }
        }
      }
    }
    div = null; delete div;
  })();

/*
 * options for clueTip
 *
 * each one can be explicitly overridden by changing its value.
 * for example: $.fn.cluetip.defaults.width = 200;
 * would change the default width for all clueTips to 200.
 *
 * each one can also be overridden by passing an options map to the cluetip method.
 * for example: $('a.example').cluetip({width: 200});
 * would change the default width to 200 for clueTips invoked by a link with class of "example"
 *
 */

  $.fn.cluetip.defaults = {  // set up default options
    width:            275,      // The width of the clueTip
    height:           'auto',   // The height of the clueTip
    cluezIndex:       97,       // Sets the z-index style property of the clueTip
    positionBy:       'auto',   // Sets the type of positioning: 'auto', 'mouse','bottomTop', 'fixed'
    topOffset:        15,       // Number of px to offset clueTip from top of invoking element
    leftOffset:       15,       // Number of px to offset clueTip from left of invoking element
    local:            false,    // Whether to use content from the same page for the clueTip's body
    localPrefix:      null,       // string to be prepended to the tip attribute if local is true
    localIdSuffix:    null,     // string to be appended to the cluetip content element's id if local is true
    hideLocal:        true,     // If local option is set to true, this determines whether local content
                                // to be shown in clueTip should be hidden at its original location
    attribute:        'rel',    // the attribute to be used for fetching the clueTip's body content
    titleAttribute:   'title',  // the attribute to be used for fetching the clueTip's title
    splitTitle:       '',       // A character used to split the title attribute into the clueTip title and divs
                                // within the clueTip body. more info below [6]
    escapeTitle:      false,    // whether to html escape the title attribute
    showTitle:        true,     // show title bar of the clueTip, even if title attribute not set
    cluetipClass:     'default',// class added to outermost clueTip div in the form of 'cluetip-' + clueTipClass.
    hoverClass:       '',       // class applied to the invoking element onmouseover and removed onmouseout
    waitImage:        true,     // whether to show a "loading" img, which is set in jquery.cluetip.css
    cursor:           'help',
    arrows:           false,    // if true, displays arrow on appropriate side of clueTip
    dropShadow:       true,     // set to false if you don't want the drop-shadow effect on the clueTip
    dropShadowSteps:  3,        // adjusts the size of the drop shadow
    sticky:           false,    // keep visible until manually closed
    mouseOutClose:    false,    // close when clueTip is moused out
    activation:       'hover',  // set to 'click' to force user to click to show clueTip
                                // set to 'focus' to show on focus of a form element and hide on blur
    clickThrough:     false,    // if true, and activation is not 'click', then clicking on link will take user to the link's href,
                                // even if href and tipAttribute are equal
    tracking:         false,    // if true, clueTip will track mouse movement (experimental)
    delayedClose:     0,        // close clueTip on a timed delay (experimental)
    closePosition:    'top',    // location of close text for sticky cluetips; can be 'top' or 'bottom' or 'title'
    closeText:        'Close',  // text (or HTML) to to be clicked to close sticky clueTips
    truncate:         0,        // number of characters to truncate clueTip's contents. if 0, no truncation occurs
    pathAjax: 			'',
    urlAjax:			'',
    // effect and speed for opening clueTips
    fx: {
                      open:       'show', // can be 'show' or 'slideDown' or 'fadeIn'
                      openSpeed:  ''
    },

    // settings for when hoverIntent plugin is used
    hoverIntent: {
                      sensitivity:  3,
              			  interval:     50,
              			  timeout:      0
    },

    // short-circuit function to run just before clueTip is shown.
    onActivate:       function(e) {return true;},
    // function to run just after clueTip is shown.
    onShow:           function(ct, ci){},
    // function to run just after clueTip is hidden.
    onHide:           function(ct, ci){},
    // whether to cache results of ajax request to avoid unnecessary hits to server
    ajaxCache:        true,

    // process data retrieved via xhr before it's displayed
    ajaxProcess:      function(data) {
                        data = data.replace(/<(script|style|title)[^<]+<\/(script|style|title)>/gm, '').replace(/<(link|meta)[^>]+>/g,'');
                        return data;
    },

    // can pass in standard $.ajax() parameters. Callback functions, such as beforeSend,
    // will be queued first within the default callbacks.
    // The only exception is error, which overrides the default
    ajaxSettings: {
                      // error: function(ct, ci) { /* override default error callback */ }
                      // beforeSend: function(ct, ci) { /* called first within default beforeSend callback }
                      dataType: 'html'
    },
    debug: false
  };


/*
 * Global defaults for clueTips. Apply to all calls to the clueTip plugin.
 *
 * @example $.cluetip.setup({
 *   insertionType: 'prependTo',
 *   insertionElement: '#container'
 * });
 *
 * @property
 * @name $.cluetip.setup
 * @type Map
 * @cat Plugins/tooltip
 * @option String insertionType: Default is 'appendTo'. Determines the method to be used for inserting the clueTip into the DOM. Permitted values are 'appendTo', 'prependTo', 'insertBefore', and 'insertAfter'
 * @option String insertionElement: Default is 'body'. Determines which element in the DOM the plugin will reference when inserting the clueTip.
 *
 */

  var insertionType = 'appendTo', insertionElement = 'body';

  $.cluetip.setup = function(options) {
    if (options && options.insertionType && (options.insertionType).match(/appendTo|prependTo|insertBefore|insertAfter/)) {
      insertionType = options.insertionType;
    }
    if (options && options.insertionElement) {
      insertionElement = options.insertionElement;
    }
  };

})(jQuery);

$(document).ready(function(){
	$('.tooltips').cluetip({
		splitTitle: '|',
		cluetipClass: 'jtip',
		arrows: true,
		//sticky: true,
		clickThrough: true,
		closePosition: 'title',
		closeText: 'x'
	});
});
function onTabClick (parentTab, currentId, endId) {
	//remove all tag <li> class is 'tab-active'
	$('#' + parentTab + '>div.tab>ul>li').each(function (i) {
		$(this).removeClass('tab-active');
	});
	//add class 'tab-active'
	$('#' + currentId).addClass('tab-active');
	
	if (currentId != endId)
		$('#' + endId).attr('class', 'last-arround');
	else
		$('#' + endId).attr('class', 'tab-active');
	
	//hide all tag <div>
	$('#' + parentTab + '>div.boxmodule-cont>div').each(function (i) {
		$(this).hide();
	});
	//show div
	$('#' + currentId + 'Box').show();
}

//Đổi giá trị giữa 2 TAG có id a và b
function isLandValue (a, b){
	var tmp = $('#' + a).html();
	
	$('#' + a).html( $('#' + b).html() );
	$('#' + b).html(tmp);
}

//Đổi id giữa 2 TAG có id là a và b
function isLandId (a, b){
	$('#' + a).attr('id', 'id_temp_a');
	$('#' + b).attr('id', 'id_temp_b');
	
	$('#id_temp_a').attr('id', b);
	$('#id_temp_b').attr('id', a);
}

//Đổi class giữa 2 TAG có id là a và b
function isLandClass (a, b){
	var tmp = $('#' + a).attr("class");
	$('#' + a).attr("class", $('#' + b).attr("class"));
	$('#' + b).attr("class", tmp);
}

function changeTab(tabId, boxId, fnc, type)
{
	if(type == 1) {
		dataBoxModel [boxId].model_ajax_status_2 = false; 
		dataBoxModel [boxId].curentTab = tabId;
		showTab(dataBoxModel [boxId].curentTab,boxId, dataBoxModel [boxId].totalTabModel, dataBoxModel [boxId].dataTabModel);
	} else {
		dataBoxModel [boxId].items_ajax_status = false;
		dataBoxModel [boxId].curentTab = tabId;
		dataBoxModel [boxId].currentIndexTabItem = getCurrentIndexItemByTab (tabId,dataBoxModel [boxId].totalTabItem,dataBoxModel [boxId].dataTabItem);
	}
	
	$('#listTab'+boxId+' .active').removeClass('active');
	$('#tab'+boxId+tabId).addClass('active');
	$('#tabli'+boxId+tabId).addClass('active');
	
	if($('#listItem'+boxId+tabId).length > 0)
	{
		if(type == 1) {
			dataBoxModel [boxId].model_ajax_status_2 = true; 
		} else {
			dataBoxModel [boxId].items_ajax_status = true;
		}
		
		$('#listTabItem'+boxId+' .listProduct').hide();
		$("#listItem"+boxId+tabId).show();
	}
	else
	{
		$.ajax({
			  url: "ajax.php",
			  global: false,
			  type: "POST",
			  data: {
					'fnc': fnc,
					'path': "homepage",
					'type': type,
					'tab_id': tabId						
			  },			      
			  dataType: "html",			  
			  success: function(response, status){
				  $('#listTabItem'+boxId+' .listProduct').hide();
				  $("#listTabItem"+boxId).append(response);
			},
			 complete : function (jqXHR, textStatus) {
				if(type == 1) {
					dataBoxModel [boxId].model_ajax_status_2 = true; 
				} else {
					dataBoxModel [boxId].items_ajax_status = true;
				}
			}
		});
	}	
}

var getCurrentIndexByTab = function (currentTab, totalTabModel, dataTabModel) {
	for ( var i = 0; i <= totalTabModel - 1; i ++) {
		if (dataTabModel [i] ['tab_id'] == currentTab) {
			return i;
		}
	}
}

var getCurrentIndexItemByTab = function (currentTab, totalTabItem, dataTabItem) {
	for ( var i = 0; i <= totalTabItem -1; i ++) {
		if (dataTabItem [i] ['tab_id'] == currentTab) {
			return i;
		}
	}
}

var showModelDetail = function  (index, boxId) {
	buildDetailModel (dataBoxModel [boxId].dataModelTab [dataBoxModel [boxId].curentTab] [index],boxId);
}

var showTab = function (curentTab, boxId, totalTabModel, dataTabModel) {
	
	dataBoxModel [boxId].model_ajax_status_1 = false;
	//console.log (getCurrentIndexByTab (curentTab));
	dataBoxModel [boxId].currentIndexTabModel = getCurrentIndexByTab (curentTab,totalTabModel,dataTabModel);
	
	var params = {};
	if (dataBoxModel [boxId].dataModelTab [curentTab]) {
		dataBoxModel [boxId].model_ajax_status_1 = true;
		buildDetailModel (dataBoxModel [boxId].dataModelTab [curentTab] [0], boxId);
		buildListModel (dataBoxModel [boxId].dataModelTab [curentTab], boxId);
	} else {
		params['path'] = 'homepage';
		params['fnc'] = 'item_market';
		params['cmd'] = 'getModelData';
		params['tab_id'] = curentTab;
		
		var div_model = $('#model_detail'+boxId);
		var ul_list_model = $('#showListModel'+boxId);
		
		div_model.html('<div style = "padding:25px 120px;width:200px"><img src="'
				+ root_url
				+ 'webskins/javascripts/colorOverlay/images/loading.gif" /> <span style="line-height:32px">Đang tải dữ liệu...</span></div>');
		
		ul_list_model.html('<li class="no-bdr" style = "padding:25px 140px;width:200px"><img src="'
				+ root_url
				+ 'webskins/javascripts/colorOverlay/images/loading.gif" /> <span style="line-height:32px">Đang tải dữ liệu...</span></li>');
		
		$.ajax({
			'url' : root_url + 'ajax.php',
			'data' : params,
			'method' : 'get',
			'dataType' : 'json',
			'success' : function(response) {
				if (response) {
					dataBoxModel [boxId].dataModelTab [curentTab] = response;
					buildListModel (dataBoxModel [boxId].dataModelTab [curentTab], boxId);
					buildDetailModel (dataBoxModel [boxId].dataModelTab [curentTab] [0], boxId);
				};
			},
			'complete' : function (jqXHR, textStatus) {
				dataBoxModel [boxId].model_ajax_status_1 = true;
			}
		});
	}
}

function buildListModel (dataModelTab, boxId) {
	var ul_list_model = $('#showListModel'+boxId);
	var html_li_1 = '<li><div>';
	var html_li_2 = '<li class="no-bdr"><div>';
	var _ga = '';
	//for(var i = 0; i <=7 ;i++) {
	var index = 0;
	for (var i in dataModelTab) {
		_ga = 'onClick="_gaq.push(['+"'_trackEvent'"+",'Item market (hitech)','View','"+dataModelTab [i] ['model_title']+"']);"+'"';
		index ++;
		if (i <= 3) {
			html_li_1 += '<p><a '+_ga+' href="'+ dataModelTab [i] ['model_link'] +'" onmouseover = "showModelDetail (' + i + ',' + boxId + ')"><span>' + index + '</span>' + dataModelTab [i] ['model_title'] + '</a></p>';
		} else {
			html_li_2 += '<p><a '+_ga+' href="'+ dataModelTab [i] ['model_link'] +'" onmouseover = "showModelDetail (' + i + ',' + boxId + ')"><span>' + index + '</span>' + dataModelTab [i] ['model_title'] + '</a></p>';
		}
	}
	ul_list_model.html ([html_li_1 + '</div></li>',
						 html_li_2 + '</div></li>',].join(''));	
}

function buildDetailModel (dataModelTab, boxId) {
	
	var div_model = $('#model_detail'+boxId);
	var _ga = '';
	_ga = 'onClick="_gaq.push(['+"'_trackEvent'"+",'Item market (hitech)','View','"+dataModelTab ['model_title_quotes']+"']);"+'"';
	
	div_model.html (['<p class="img-120 bottom"><a '+_ga+' href="'+ dataModelTab ['model_link'] +'">'+ dataModelTab ['img'] +'</a></p>',
					'<p>&nbsp;</p>',
					'<p>Model: <a '+_ga+' href="'+ dataModelTab ['model_link'] +'">'+ dataModelTab ['model_title'] +'</a></p>',
					//'<p>Giá tham khảo: <span class="price">'+ dataModelTab ['price'] +' VNĐ</span></p>',
					'<p class="bottom"><span> Có '+ dataModelTab ['number'] +' tin đăng bán.</span></p>'].join(''));
}

var Timeout_ID = '';
function display_heart_banner(direct)
{
	var totalHeart = $("#totalHeart").val();
	
	$("#heart_"+currentHeart).hide();
	$("#thumb"+currentHeart).removeClass('active');
	if(direct == '-')
		currentHeart = currentHeart - 1;
	else 
		currentHeart = currentHeart + 1;
	if(currentHeart > totalHeart) currentHeart = 1;
	else 
		if(currentHeart == 0)
			currentHeart = totalHeart;
	
	$("#heart_"+currentHeart).show();
	$("#thumb"+currentHeart).addClass('active');
	clearTimeout(Timeout_ID);
	setTimeOutHeart();
}
$(function()
{
	display_heart_banner('+');
});

function clearTimeOutHeart() {
	clearTimeout(Timeout_ID);
}

function setTimeOutHeart()
{
	Timeout_ID = setTimeout("display_heart_banner('+')",5000);
}
function change_banner(i)
{
	clearTimeout(Timeout_ID);	
	if(i != currentHeart)
	{
		$("#heart_"+currentHeart).hide();
		$("#thumb"+currentHeart).removeClass('active');
		currentHeart = i;
		$("#heart_"+currentHeart).show();
		$("#thumb"+currentHeart).addClass('active');
	}	
};

function viewCommunity()
{
	if($('#commNew').attr('class') == 'tab-active')
		window.open ("?portal=community");
	else window.open ("?portal=community");
};

function searchEbay()
{
	var keywrodEbay = $("#keywrodEbay").val();
	//alert(keywrodEbay);
	window.location = "?portal=ebay&page=browse&keyword="+keywrodEbay;
	return false;
};

/*$(function()
	{
		$.ajax({
			  url: "ajax.php",
			  global: false,
			  type: "GET",
			  data: {
					'fnc': 'item_suggest',
					'path': "homepage"			
			  },			      
			  dataType: "html",			  
			  success: function(response, status){
				 $("#itemSugget").html(response);
			}
		});
	
	}
)*/

$(function(){
	var category_alias = $('#category_alias');
	
	category_alias.find('.list-categ li.cate-level1').hoverDelay({
		  'over': function() {
			   var ul = $(this).find('ul.sub-categ');
				ul.css('display', 'block');
				var distance = $(window).height() - ($(this).position().top + ul.height())
				if (distance<0) {
					ul.css('top', distance-50);
				}
				$(this).addClass('hoverIndex').addClass('active');
		  }, 
		  'out': function() {
				$(this).find('ul.sub-categ').css('display', 'none');
				$(this).removeClass('hoverIndex').removeClass('active');
		  }
	  })
});
function mycarousel_itemAddCallback(carousel, first, last, data)
{
	carousel.size(parseInt(data.total));
	for(var i=0; i<data.total; i++){
		carousel.add(i+1, data.html[i]);
	}
}

function mycarousel_productCart(carousel, state)
{    
	// Check if the requested items already exist
	if (carousel.has(carousel.first, carousel.last)){
		return;
	}
	$.ajax({        
		url:'ajax.php?fnc=product.cart.process&path=header_footer',        
		type:'GET',
		dataType:'json',
		success: function(data){            
			$('#sub-foobar-loading').hide();
			if(data.code == 1){
				mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, data);
				$('p#total-money').html('Tổng cộng: <b>'+data.total_money+ ' VNĐ</b>');
				var int_total_money = replaceAll('.','',data.total_money);                
				$('#int_total_money').val(int_total_money);
				if($('#fooBar').css('bottom') != '140px' )
					$('#fooBar').animate({"bottom": "+=140px"}, "slow");
			}
			else{                
				$('#noitem-cart').fadeIn(300).delay(3000).fadeOut(100);
				if($('#fooBar').css('bottom') == '140px' )
					$('#fooBar').animate({"bottom": "-=140px"}, "slow");
			}
		}
	});
}

function mycarousel_productSuggest(carousel, state)
{
	// Check if the requested items already exist
	if (carousel.has(carousel.first, carousel.last)){
		return;
	}
	$.ajax({    
		url:'ajax.php?fnc=Footer.Product.Suggest&path=header_footer',        
		type:'GET',
		dataType:'json',
		success: function(data){
			$('#sub-foobar-loading').hide();                        
			if(data.code == 1){                              
				mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, data);
				if($('#fooBar').css('bottom') != '140px' )
					$('#fooBar').animate({"bottom": "+=140px"}, "slow");
			}
			else{
				$('#noitem-suggest').fadeIn(300).delay(3000).fadeOut(100);                
				if($('#fooBar').css('bottom') == '140px' )
					$('#fooBar').animate({"bottom": "-=140px"}, "slow");
			}
		}
	});
}


function mycarousel_productView(carousel, state)
{
	// Check if the requested items already exist
	if (carousel.has(carousel.first, carousel.last)){
		return;
	}
	$.ajax({     
		url:'ajax.php?fnc=Footer.Product.View&path=header_footer',        
		type:'GET',
		dataType:'json',
		success: function(data){            
			$('#sub-foobar-loading').hide();          
			if(data.code == 1){                
				mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, data);
				if($('#fooBar').css('bottom') != '140px' )
					$('#fooBar').animate({"bottom": "+=140px"}, "slow");
			}
			else{                
				$('#noitem-view').fadeIn(300).delay(3000).fadeOut(100);
				if($('#fooBar').css('bottom') == '140px' )
					$('#fooBar').animate({"bottom": "-=140px"}, "slow");
			}
		}
	}); 
}

//San pham trong gio hang
function getProductCat(){
	//active
	$('.mybags a').addClass('active');
	$('.saw-pro a').removeClass('active');
	$('.guide-pro a').removeClass('active');
	$('#notice').removeClass('active')
	
	$('#mycarousel_cart').addClass('have-checkout');//display class checkout
	$('#foobar-innersub').addClass('haveCO');
		 
	$('#sub-foobar-loading').show();    
	$('.checkout').show();
	$('#mycarousel_view').hide();
	$('#mycarousel_suggest').hide();    
	var length = $('#mycarousel_cart ul').html().length;    
	if(length == 0){
		jQuery('#mycarousel_cart').jcarousel({
			itemLoadCallback: mycarousel_productCart});
	}else{
		$('#sub-foobar-loading').hide();
		$('#mycarousel_cart').show();
		if($('#mycarousel_cart ul li').html().length == 0){            
			if($('#fooBar').css('bottom') == '140px' )
				$('#fooBar').animate({"bottom": "-=140px"}, "slow");
			$('#noitem-cart').fadeIn(300).delay(3000).fadeOut(100);  
		}
		else if($('#fooBar').css('bottom') == '0px')
			$('#fooBar').animate({"bottom": "+=140px"}, "slow");      
	}
}
//San pham vua xem
function getProductView(){
	//active
	$('.saw-pro a').addClass('active');
	$('.mybags a').removeClass('active');   
	$('.guide-pro a').removeClass('active');
	$('#notice').removeClass('active')
	
	$('#foobar-innersub').removeClass('haveCO');
	
	$('#sub-foobar-loading').show();
	$('.checkout').hide();
	$('#mycarousel_cart').hide();
	$('#mycarousel_suggest').hide();
	var length = $('#mycarousel_view ul').html().length;
	if(length == 0){
		jQuery('#mycarousel_view').jcarousel({
			itemLoadCallback: mycarousel_productView});
	}else{
		$('#sub-foobar-loading').hide();
		$('#mycarousel_view').show();
		if($('#mycarousel_view ul li').html().length == 0){
			if($('#fooBar').css('bottom') == '140px' )
				$('#fooBar').animate({"bottom": "-=140px"}, "slow");
			$('#noitem-view').fadeIn(300).delay(3000).fadeOut(100);  
		}
		else if($('#fooBar').css('bottom') != '140px' )
			$('#fooBar').animate({"bottom": "+=140px"}, "slow");
		
	} 
}
//San pham goi y
function getProductSuggest(){
	//active
	$('.guide-pro a').addClass('active');
	$('.saw-pro a').removeClass('active');
	$('.mybags a').removeClass('active');   
	$('#notice').removeClass('active')
	
	$('#foobar-innersub').removeClass('haveCO');
	
	$('#sub-foobar-loading').show();
	$('.checkout').hide();
	$('#mycarousel_cart').hide();
	$('#mycarousel_view').hide();
	var length = $('#mycarousel_suggest ul').html().length;
	if(length == 0){        
		jQuery('#mycarousel_suggest').jcarousel({
			itemLoadCallback: mycarousel_productSuggest});
	}else{
		$('#sub-foobar-loading').hide();
		$('#mycarousel_suggest').show();
		if($('#mycarousel_suggest ul li').html().length == 0){            
			if($('#fooBar').css('bottom') == '140px' )
				$('#fooBar').animate({"bottom": "-=140px"}, "slow");
			$('#noitem-suggest').fadeIn(300).delay(3000).fadeOut(100);  
		}else if($('#fooBar').css('bottom') != '140px' )
			$('#fooBar').animate({"bottom": "+=140px"}, "slow");
	}
}

//Ham xoa san pham trong gio hang
function delItemFooterBar(id,obj){
		var rel = parseInt(obj.parent().parent().attr('jcarouselindex'));
		$('#mycarousel_cart').jcarousel('removeAndAnimate', rel);
		$.ajax({
		url:'ajax.php?fnc=Footer.Product.Del.Cart&path=header_footer',
		data:{id: id},
		type:'GET',
		success: function(data){            
			if(data== 1){
				var num_cart = parseInt($('#pCart').html());
				if(num_cart > 0){
					num_cart--;
					$('#pCart').html(num_cart); //so san pham trong gio hang
													 
					//Cap nhat tong so tien thanh toan                    
					var new_total = parseInt($('#int_total_money').val()) - parseInt(obj.attr('rel'));
					$('#int_total_money').val(new_total);
					$('p#total-money').html('Tổng cộng: <b>'+formatMoney(new_total,0,'','.')+ ' VNĐ</b>');                    
					if(num_cart == 0){
						$('#fooBar').animate({"bottom": "-=140px"}, "slow");
					}
				}
				return;
			}
			else{
				jAlert('Có lỗi trong quá trình thực hiện','Thông báo');
				return;
			}
		}        
	});
}

//Xoa san pham vua xem & san pham da luu
function delItemView(id,obj){
	var jcarouselindex = obj.parent().parent().parent().attr('jcarouselindex');    
	$('#mycarousel_view').jcarousel('removeAndAnimate', jcarouselindex);    
	var rel = obj.attr('rel');
	if(rel == 1)
		cmd = 'save';
	else cmd = 'view';    
	//Goi ajax xóa sản phẩm đã xem & lưu    
	$.ajax({
		url:'ajax.php?fnc=delProductView&path=header_footer',
		data:{id: id, 'type':cmd},
		type:'GET',
		dataType:'json',
		success: function(data){            
			if(data.code == 0){                           
				$('#fooBar').animate({"bottom": "-=140px"}, "slow");
			}else return;
			
		}
	});
}

function saveProduct(id){    
	var userId = $("a.save-follow").attr('rel');
	$.post("ajax.php?fnc=likeOrTrack",{'item_id':id, 'action':1, 'user_id':userId ,'path':'item_view'},function(data)
		{
			if(data == 1)
			{				
				jAlert('Sản phẩm đã được lưu vào danh sách','Thông báo'); 
				$('a#fooBar-pr-'+id).removeClass('like-pro');
				$('a#fooBar-pr-'+id).addClass('like-pro-hover'); 
				$("#save-follow-"+id).hide();
			}
			else
				jAlert(data, ' Xin lỗi');
		}); 
}

function replaceAll(strTarget,strSubString,strText){ 
	var intIndexOfMatch = strText.indexOf( strTarget );    
	while (intIndexOfMatch != -1){
		strText = strText.replace( strTarget, strSubString )     
		intIndexOfMatch = strText.indexOf( strTarget );
	}
	return( strText );
}

function formatMoney(n, c, d, t){
	c = isNaN(c = Math.abs(c)) ? 2 : c,
	d = d == undefined ? "," : d,
	t = t == undefined ? "." : t, s = n < 0 ? "-" : "", 
	i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", 
	j = (j = i.length) > 3 ? j % 3 : 0;
	return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};

function closeSlideProduct(){
	//$('#sub-foobar.innersub').hide();
	//$('#mycarousel_suggest ul').hide();
	//$('#mycarousel_view ul').hide();
	//$('#mycarousel_cart ul').hide();
	if($('#fooBar').css('bottom') == '140px'){
		$('#fooBar').animate({"bottom": "-=140px"}, "slow");
		$('.guide-pro a').removeClass('active');
		$('.saw-pro a').removeClass('active');
		$('.mybags a').removeClass('active');  
	}
	  
}

function viewNotice(){
		$.ajax({
		url: 'ajax.php?fnc=Footer.Notification&path=header_footer',
		type: 'POST',
		dataType: 'json',        
		success: function(data){
			if(data.code==1){
				$('.subalert').css('display','block');
				$('.inner-subalert').html(data.html);
			}else if(data.code == 0){			
				$('.subalert').css('display','block');                
				$('.inner-subalert').html("<p>&nbsp;&nbsp;Hiện chưa có thông báo</p>");  
			}else if(data.code == 2){
				$('.subalert').css('display','block');                
				$('.inner-subalert').html("<p>&nbsp;&nbsp;Bạn chưa đăng nhập</p>"); 
			}
		}
	});
}
$(document).ready(function(){
	$(".joinfriend").livequery("click", function(e){
		 var friend_id = $(this).attr('rel');
		$.ajax({
			beforeSend: function(){
				 $(".submit-orange").attr('disabled', 'disabled');
				 $(".cancelfriend").attr('disabled', 'disabled');   
			},
			url:'ajax.php?path=dashboard&fnc=friend',
			type:'GET',
			dataType:'json',
			data:{'friend_id':friend_id,'todo':'joinfriend'},
			success:function(data)
			{
				if(data.code == 1)
				{
					$('.button_active_'+friend_id).css('display' , 'none');
					jAlert("Bạn đã kết bạn thành công", "Thông báo");
				}
				else                
					jAlert(data.html , 'Thông báo');
			}
		});                  
	 });
	 $(".cancelfriend").livequery("click", function(e){
		 var friend_id = $(".joinfriend").attr('rel');
		$.ajax({
			beforeSend: function(){
				 $(this).attr('disabled', 'disabled');
				 $(".submit-orange").attr('disabled', 'disabled');   
			},
			url:'ajax.php?path=dashboard&fnc=friend',
			type:'GET',
			dataType:'json',
			data:{'friend_id':friend_id,'todo':'delWai'},
			success:function(data)
			{
				if(data.code == 1)
				{
					$('.button_active_'+friend_id).css('display' , 'none');
					jAlert("Bạn đã hủy bỏ yêu cầu kết bạn của người này!", "Thông báo");
				}
				else                
					jAlert(data.html , 'Thông báo');
			}
		});    
		
	 });
});

(function($) {
    // Default configuration properties.
    var defaults = {
        vertical: false,
        rtl: false,
        start: 1,
        offset: 1,
        size: null,
        scroll: 2,
        visible: null,
        animation: 'normal',
        easing: 'swing',
        auto: 0,
        wrap: null,
        initCallback: null,
        reloadCallback: null,
        itemLoadCallback: null,
        itemFirstInCallback: null,
        itemFirstOutCallback: null,
        itemLastInCallback: null,
        itemLastOutCallback: null,
        itemVisibleInCallback: null,
        itemVisibleOutCallback: null,
        buttonNextHTML: '<a><div></div></a>',
        buttonPrevHTML: '<span><div></div></span>',
        buttonNextEvent: 'click',
        buttonPrevEvent: 'click',
        buttonNextCallback: null,
        buttonPrevCallback: null,
        itemFallbackDimension: null
    }, windowLoaded = false;
    $(window).bind('load.jcarousel', function() { windowLoaded = true; });

    /**
     * The jCarousel object.
     *
     * @constructor
     * @class jcarousel
     * @param e {HTMLElement} The element to create the carousel for.
     * @param o {Object} A set of key/value pairs to set as configuration properties.
     * @cat Plugins/jCarousel
     */
    $.jcarousel = function(e, o) {
        this.options    = $.extend({}, defaults, o || {});

        this.locked          = false;
        this.autoStopped     = false;

        this.container       = null;
        this.clip            = null;
        this.list            = null;
        this.buttonNext      = null;
        this.buttonPrev      = null;
        this.buttonNextState = null;
        this.buttonPrevState = null;

        // Only set if not explicitly passed as option
        if (!o || o.rtl === undefined) {
            this.options.rtl = ($(e).attr('dir') || $('html').attr('dir') || '').toLowerCase() == 'rtl';
        }

        this.wh = !this.options.vertical ? 'width' : 'height';
        this.lt = !this.options.vertical ? (this.options.rtl ? 'right' : 'left') : 'top';

        // Extract skin class
        var skin = '', split = e.className.split(' ');

        for (var i = 0; i < split.length; i++) {
            if (split[i].indexOf('jcarousel-skin') != -1) {
                $(e).removeClass(split[i]);
                skin = split[i];
                break;
            }
        }

        if (e.nodeName.toUpperCase() == 'UL' || e.nodeName.toUpperCase() == 'OL') {
            this.list = $(e);
            this.container = this.list.parent();

            if (this.container.hasClass('jcarousel-clip')) {
                if (!this.container.parent().hasClass('jcarousel-container')) {
                    this.container = this.container.wrap('<div></div>');
                }

                this.container = this.container.parent();
            } else if (!this.container.hasClass('jcarousel-container')) {
                this.container = this.list.wrap('<div></div>').parent();
            }
        } else {
            this.container = $(e);
            this.list = this.container.find('ul,ol').eq(0);
        }

        if (skin !== '' && this.container.parent()[0].className.indexOf('jcarousel-skin') == -1) {
            this.container.wrap('<div class=" '+ skin + '"></div>');
        }

        this.clip = this.list.parent();

        if (!this.clip.length || !this.clip.hasClass('jcarousel-clip')) {
            this.clip = this.list.wrap('<div></div>').parent();
        }

        this.buttonNext = $('.jcarousel-next', this.container);

        if (this.buttonNext.size() === 0 && this.options.buttonNextHTML !== null) {
            this.buttonNext = this.clip.after(this.options.buttonNextHTML).next();
        }

        this.buttonNext.addClass(this.className('jcarousel-next'));

        this.buttonPrev = $('.jcarousel-prev', this.container);

        if (this.buttonPrev.size() === 0 && this.options.buttonPrevHTML !== null) {
            this.buttonPrev = this.clip.after(this.options.buttonPrevHTML).next();
        }

        this.buttonPrev.addClass(this.className('jcarousel-prev'));

        this.clip.addClass(this.className('jcarousel-clip')).css({
            overflow: 'hidden',
            position: 'relative'
        });

        this.list.addClass(this.className('jcarousel-list')).css({
            overflow: 'hidden',
            position: 'relative',
            top: 0,
            margin: 0,
            padding: 0
        }).css((this.options.rtl ? 'right' : 'left'), 0);

        this.container.addClass(this.className('jcarousel-container')).css({
            position: 'relative'
        });

        if (!this.options.vertical && this.options.rtl) {
            this.container.addClass('jcarousel-direction-rtl').attr('dir', 'rtl');
        }

        var di = this.options.visible !== null ? Math.ceil(this.clipping() / this.options.visible) : null;
        var li = this.list.children('li');

        var self = this;

        if (li.size() > 0) {
            var wh = 0, j = this.options.offset;
            li.each(function() {
                self.format(this, j++);
                wh += self.dimension(this, di);
            });

            this.list.css(this.wh, (wh + 100) + 'px');

            // Only set if not explicitly passed as option
            if (!o || o.size === undefined) {
                this.options.size = li.size();
            }
        }

        // For whatever reason, .show() does not work in Safari...
        this.container.css('display', 'block');
        this.buttonNext.css('display', 'block');
        this.buttonPrev.css('display', 'block');

        this.funcNext   = function() { self.next(); };
        this.funcPrev   = function() { self.prev(); };
        this.funcResize = function() { self.reload();};

        if (this.options.initCallback !== null) {
            this.options.initCallback(this, 'init');
        }

        if (!windowLoaded && $.browser.safari) {
            this.buttons(false, false);
            $(window).bind('load.jcarousel', function() { self.setup(); });
        } else {
            this.setup();
        }
    };

    // Create shortcut for internal use
    var $jc = $.jcarousel;

    $jc.fn = $jc.prototype = {
        jcarousel: '0.2.7'
    };

    $jc.fn.extend = $jc.extend = $.extend;

    $jc.fn.extend({
        /**
         * Setups the carousel.
         *
         * @method setup
         * @return undefined
         */
        setup: function() {
            this.first     = null;
            this.last      = null;
            this.prevFirst = null;
            this.prevLast  = null;
            this.animating = false;
            this.timer     = null;
            this.tail      = null;
            this.inTail    = false;

            if (this.locked) {
                return;
            }

            this.list.css(this.lt, this.pos(this.options.offset) + 'px');
            var p = this.pos(this.options.start, true);
            this.prevFirst = this.prevLast = null;
            this.animate(p, false);

            //$(window).unbind('resize.jcarousel', this.funcResize).bind('resize.jcarousel', this.funcResize);
        },

        /**
         * Clears the list and resets the carousel.
         *
         * @method reset
         * @return undefined
         */
        reset: function() {
            this.list.empty();

            this.list.css(this.lt, '0px');
            this.list.css(this.wh, '10px');

            if (this.options.initCallback !== null) {
                this.options.initCallback(this, 'reset');
            }

            this.setup();
        },

        /**
         * Reloads the carousel and adjusts positions.
         *
         * @method reload
         * @return undefined
         */
        reload: function() {
            if (this.tail !== null && this.inTail) {
                this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + this.tail);
            }

            this.tail   = null;
            this.inTail = false;

            if (this.options.reloadCallback !== null) {
                this.options.reloadCallback(this);
            }

            if (this.options.visible !== null) {
                var self = this;
                var di = Math.ceil(this.clipping() / this.options.visible), wh = 0, lt = 0;
                this.list.children('li').each(function(i) {
                    wh += self.dimension(this, di);
                    if (i + 1 < self.first) {
                        lt = wh;
                    }
                });

                this.list.css(this.wh, wh + 'px');
                this.list.css(this.lt, -lt + 'px');
            }

            this.scroll(this.first, false);
        },

        /**
         * Locks the carousel.
         *
         * @method lock
         * @return undefined
         */
        lock: function() {
            this.locked = true;
            this.buttons();
        },

        /**
         * Unlocks the carousel.
         *
         * @method unlock
         * @return undefined
         */
        unlock: function() {
            this.locked = false;
            this.buttons();
        },

        /**
         * Sets the size of the carousel.
         *
         * @method size
         * @return undefined
         * @param s {Number} The size of the carousel.
         */
        size: function(s) {
            if (s !== undefined) {
                this.options.size = s;
                if (!this.locked) {
                    this.buttons();
                }
            }

            return this.options.size;
        },

        /**
         * Checks whether a list element exists for the given index (or index range).
         *
         * @method get
         * @return bool
         * @param i {Number} The index of the (first) element.
         * @param i2 {Number} The index of the last element.
         */
        has: function(i, i2) {
            if (i2 === undefined || !i2) {
                i2 = i;
            }

            if (this.options.size !== null && i2 > this.options.size) {
                i2 = this.options.size;
            }

            for (var j = i; j <= i2; j++) {
                var e = this.get(j);
                if (!e.length || e.hasClass('jcarousel-item-placeholder')) {
                    return false;
                }
            }

            return true;
        },

        /**
         * Returns a jQuery object with list element for the given index.
         *
         * @method get
         * @return jQuery
         * @param i {Number} The index of the element.
         */
        get: function(i) {
            return $('.jcarousel-item-' + i, this.list);
        },

        /**
         * Adds an element for the given index to the list.
         * If the element already exists, it updates the inner html.
         * Returns the created element as jQuery object.
         *
         * @method add
         * @return jQuery
         * @param i {Number} The index of the element.
         * @param s {String} The innerHTML of the element.
         */
        add: function(i, s) {
            var e = this.get(i), old = 0, n = $(s);

            if (e.length === 0) {
                var c, j = $jc.intval(i);
                e = this.create(i);
                while (true) {
                    c = this.get(--j);
                    if (j <= 0 || c.length) {
                        if (j <= 0) {
                            this.list.prepend(e);
                        } else {
                            c.after(e);
                        }
                        break;
                    }
                }
            } else {
                old = this.dimension(e);
            }

            if (n.get(0).nodeName.toUpperCase() == 'LI') {
                e.replaceWith(n);
                e = n;
            } else {
                e.empty().append(s);
            }

            this.format(e.removeClass(this.className('jcarousel-item-placeholder')), i);

            var di = this.options.visible !== null ? Math.ceil(this.clipping() / this.options.visible) : null;
            var wh = this.dimension(e, di) - old;

            if (i > 0 && i < this.first) {
                this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - wh + 'px');
            }

            this.list.css(this.wh, $jc.intval(this.list.css(this.wh)) + wh + 'px');

            return e;
        },

        /**
         * Removes an element for the given index from the list.
         *
         * @method remove
         * @return undefined
         * @param i {Number} The index of the element.
         */
        remove: function(i) {
            var e = this.get(i);

            // Check if item exists and is not currently visible
            if (!e.length || (i >= this.first && i <= this.last)) {
                return;
            }

            var d = this.dimension(e);

            if (i < this.first) {
                this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + d + 'px');
            }

            e.remove();

            this.list.css(this.wh, $jc.intval(this.list.css(this.wh)) - d + 'px');
        },
        removeAndAnimate: function(i) {        
            var e = this.get(i);            
            var d = this.dimension(e);            
            if (i < this.first) this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + d + 'px');            
            e.remove();
            this.options.size--;            
            var di = this.options.visible != null ? Math.ceil(this.clipping() / this.options.visible) : null;
            var li = this.list.children('li');
            var self = this;            
            if (li.size() > 0) {
                var wh = 0, i = this.options.offset;
                li.each(function() {
                    self.format(this, i++);
                    wh += self.dimension(this, di);
                });            
                this.list.css(this.wh, wh + 'px');            
            }            
            this.scroll(0,true);
            this.buttons();
        },

        /**
         * Moves the carousel forwards.
         *
         * @method next
         * @return undefined
         */
        next: function() {
            if (this.tail !== null && !this.inTail) {
                this.scrollTail(false);
            } else {
                this.scroll(((this.options.wrap == 'both' || this.options.wrap == 'last') && this.options.size !== null && this.last == this.options.size) ? 1 : this.first + this.options.scroll);
            }
        },

        /**
         * Moves the carousel backwards.
         *
         * @method prev
         * @return undefined
         */
        prev: function() {
            if (this.tail !== null && this.inTail) {
                this.scrollTail(true);
            } else {
                this.scroll(((this.options.wrap == 'both' || this.options.wrap == 'first') && this.options.size !== null && this.first == 1) ? this.options.size : this.first - this.options.scroll);
            }
        },

        /**
         * Scrolls the tail of the carousel.
         *
         * @method scrollTail
         * @return undefined
         * @param b {Boolean} Whether scroll the tail back or forward.
         */
        scrollTail: function(b) {
            if (this.locked || this.animating || !this.tail) {
                return;
            }

            this.pauseAuto();

            var pos  = $jc.intval(this.list.css(this.lt));

            pos = !b ? pos - this.tail : pos + this.tail;
            this.inTail = !b;

            // Save for callbacks
            this.prevFirst = this.first;
            this.prevLast  = this.last;

            this.animate(pos);
        },

        /**
         * Scrolls the carousel to a certain position.
         *
         * @method scroll
         * @return undefined
         * @param i {Number} The index of the element to scoll to.
         * @param a {Boolean} Flag indicating whether to perform animation.
         */
        scroll: function(i, a) {
            if (this.locked || this.animating) {
                return;
            }

            this.pauseAuto();
            this.animate(this.pos(i), a);
        },

        /**
         * Prepares the carousel and return the position for a certian index.
         *
         * @method pos
         * @return {Number}
         * @param i {Number} The index of the element to scoll to.
         * @param fv {Boolean} Whether to force last item to be visible.
         */
        pos: function(i, fv) {
            var pos  = $jc.intval(this.list.css(this.lt));

            if (this.locked || this.animating) {
                return pos;
            }

            if (this.options.wrap != 'circular') {
                i = i < 1 ? 1 : (this.options.size && i > this.options.size ? this.options.size : i);
            }

            var back = this.first > i;

            // Create placeholders, new list width/height
            // and new list position
            var f = this.options.wrap != 'circular' && this.first <= 1 ? 1 : this.first;
            var c = back ? this.get(f) : this.get(this.last);
            var j = back ? f : f - 1;
            var e = null, l = 0, p = false, d = 0, g;

            while (back ? --j >= i : ++j < i) {
                e = this.get(j);
                p = !e.length;
                if (e.length === 0) {
                    e = this.create(j).addClass(this.className('jcarousel-item-placeholder'));
                    c[back ? 'before' : 'after' ](e);

                    if (this.first !== null && this.options.wrap == 'circular' && this.options.size !== null && (j <= 0 || j > this.options.size)) {
                        g = this.get(this.index(j));
                        if (g.length) {
                            e = this.add(j, g.clone(true));
                        }
                    }
                }

                c = e;
                d = this.dimension(e);

                if (p) {
                    l += d;
                }

                if (this.first !== null && (this.options.wrap == 'circular' || (j >= 1 && (this.options.size === null || j <= this.options.size)))) {
                    pos = back ? pos + d : pos - d;
                }
            }

            // Calculate visible items
            var clipping = this.clipping(), cache = [], visible = 0, v = 0;
            c = this.get(i - 1);
            j = i;

            while (++visible) {
                e = this.get(j);
                p = !e.length;
                if (e.length === 0) {
                    e = this.create(j).addClass(this.className('jcarousel-item-placeholder'));
                    // This should only happen on a next scroll
                    if (c.length === 0) {
                        this.list.prepend(e);
                    } else {
                        c[back ? 'before' : 'after' ](e);
                    }

                    if (this.first !== null && this.options.wrap == 'circular' && this.options.size !== null && (j <= 0 || j > this.options.size)) {
                        g = this.get(this.index(j));
                        if (g.length) {
                            e = this.add(j, g.clone(true));
                        }
                    }
                }

                c = e;
                d = this.dimension(e);
                if (d === 0) {
                    throw new Error('jCarousel: No width/height set for items. This will cause an infinite loop. Aborting...');
                }

                if (this.options.wrap != 'circular' && this.options.size !== null && j > this.options.size) {
                    cache.push(e);
                } else if (p) {
                    l += d;
                }

                v += d;

                if (v >= clipping) {
                    break;
                }

                j++;
            }

             // Remove out-of-range placeholders
            for (var x = 0; x < cache.length; x++) {
                cache[x].remove();
            }

            // Resize list
            if (l > 0) {
                this.list.css(this.wh, this.dimension(this.list) + l + 'px');

                if (back) {
                    pos -= l;
                    this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - l + 'px');
                }
            }

            // Calculate first and last item
            var last = i + visible - 1;
            if (this.options.wrap != 'circular' && this.options.size && last > this.options.size) {
                last = this.options.size;
            }

            if (j > last) {
                visible = 0;
                j = last;
                v = 0;
                while (++visible) {
                    e = this.get(j--);
                    if (!e.length) {
                        break;
                    }
                    v += this.dimension(e);
                    if (v >= clipping) {
                        break;
                    }
                }
            }

            var first = last - visible + 1;
            if (this.options.wrap != 'circular' && first < 1) {
                first = 1;
            }

            if (this.inTail && back) {
                pos += this.tail;
                this.inTail = false;
            }

            this.tail = null;
            if (this.options.wrap != 'circular' && last == this.options.size && (last - visible + 1) >= 1) {
                var m = $jc.margin(this.get(last), !this.options.vertical ? 'marginRight' : 'marginBottom');
                if ((v - m) > clipping) {
                    this.tail = v - clipping - m;
                }
            }

            if (fv && i === this.options.size && this.tail) {
                pos -= this.tail;
                this.inTail = true;
            }

            // Adjust position
            while (i-- > first) {
                pos += this.dimension(this.get(i));
            }

            // Save visible item range
            this.prevFirst = this.first;
            this.prevLast  = this.last;
            this.first     = first;
            this.last      = last;

            return pos;
        },

        /**
         * Animates the carousel to a certain position.
         *
         * @method animate
         * @return undefined
         * @param p {Number} Position to scroll to.
         * @param a {Boolean} Flag indicating whether to perform animation.
         */
        animate: function(p, a) {
            if (this.locked || this.animating) {
                return;
            }

            this.animating = true;

            var self = this;
            var scrolled = function() {
                self.animating = false;

                if (p === 0) {
                    self.list.css(self.lt,  0);
                }

                if (!self.autoStopped && (self.options.wrap == 'circular' || self.options.wrap == 'both' || self.options.wrap == 'last' || self.options.size === null || self.last < self.options.size || (self.last == self.options.size && self.tail !== null && !self.inTail))) {
                    self.startAuto();
                }

                self.buttons();
                self.notify('onAfterAnimation');

                // This function removes items which are appended automatically for circulation.
                // This prevents the list from growing infinitely.
                if (self.options.wrap == 'circular' && self.options.size !== null) {
                    for (var i = self.prevFirst; i <= self.prevLast; i++) {
                        if (i !== null && !(i >= self.first && i <= self.last) && (i < 1 || i > self.options.size)) {
                            self.remove(i);
                        }
                    }
                }
            };

            this.notify('onBeforeAnimation');

            // Animate
            if (!this.options.animation || a === false) {
                this.list.css(this.lt, p + 'px');
                scrolled();
            } else {
                var o = !this.options.vertical ? (this.options.rtl ? {'right': p} : {'left': p}) : {'top': p};
                this.list.animate(o, this.options.animation, this.options.easing, scrolled);
            }
        },

        /**
         * Starts autoscrolling.
         *
         * @method auto
         * @return undefined
         * @param s {Number} Seconds to periodically autoscroll the content.
         */
        startAuto: function(s) {
            if (s !== undefined) {
                this.options.auto = s;
            }

            if (this.options.auto === 0) {
                return this.stopAuto();
            }

            if (this.timer !== null) {
                return;
            }

            this.autoStopped = false;

            var self = this;
            this.timer = window.setTimeout(function() { self.next(); }, this.options.auto * 1000);
        },

        /**
         * Stops autoscrolling.
         *
         * @method stopAuto
         * @return undefined
         */
        stopAuto: function() {
            this.pauseAuto();
            this.autoStopped = true;
        },

        /**
         * Pauses autoscrolling.
         *
         * @method pauseAuto
         * @return undefined
         */
        pauseAuto: function() {
            if (this.timer === null) {
                return;
            }

            window.clearTimeout(this.timer);
            this.timer = null;
        },

        /**
         * Sets the states of the prev/next buttons.
         *
         * @method buttons
         * @return undefined
         */
        buttons: function(n, p) {
            if (n == null) {
                n = !this.locked && this.options.size !== 0 && ((this.options.wrap && this.options.wrap != 'first') || this.options.size === null || this.last < this.options.size);
                if (!this.locked && (!this.options.wrap || this.options.wrap == 'first') && this.options.size !== null && this.last >= this.options.size) {
                    n = this.tail !== null && !this.inTail;
                }
            }

            if (p == null) {
                p = !this.locked && this.options.size !== 0 && ((this.options.wrap && this.options.wrap != 'last') || this.first > 1);
                if (!this.locked && (!this.options.wrap || this.options.wrap == 'last') && this.options.size !== null && this.first == 1) {
                    p = this.tail !== null && this.inTail;
                }
            }

            var self = this;

            if (this.buttonNext.size() > 0) {
                this.buttonNext.unbind(this.options.buttonNextEvent + '.jcarousel', this.funcNext);

                if (n) {
                    this.buttonNext.bind(this.options.buttonNextEvent + '.jcarousel', this.funcNext);
                }

                this.buttonNext[n ? 'removeClass' : 'addClass'](this.className('jcarousel-next-disabled')).attr('disabled', n ? false : true);

                if (this.options.buttonNextCallback !== null && this.buttonNext.data('jcarouselstate') != n) {
                    this.buttonNext.each(function() { self.options.buttonNextCallback(self, this, n); }).data('jcarouselstate', n);
                }
            } else {
                if (this.options.buttonNextCallback !== null && this.buttonNextState != n) {
                    this.options.buttonNextCallback(self, null, n);
                }
            }

            if (this.buttonPrev.size() > 0) {
                this.buttonPrev.unbind(this.options.buttonPrevEvent + '.jcarousel', this.funcPrev);

                if (p) {
                    this.buttonPrev.bind(this.options.buttonPrevEvent + '.jcarousel', this.funcPrev);
                }

                this.buttonPrev[p ? 'removeClass' : 'addClass'](this.className('jcarousel-prev-disabled')).attr('disabled', p ? false : true);

                if (this.options.buttonPrevCallback !== null && this.buttonPrev.data('jcarouselstate') != p) {
                    this.buttonPrev.each(function() { self.options.buttonPrevCallback(self, this, p); }).data('jcarouselstate', p);
                }
            } else {
                if (this.options.buttonPrevCallback !== null && this.buttonPrevState != p) {
                    this.options.buttonPrevCallback(self, null, p);
                }
            }

            this.buttonNextState = n;
            this.buttonPrevState = p;
        },

        /**
         * Notify callback of a specified event.
         *
         * @method notify
         * @return undefined
         * @param evt {String} The event name
         */
        notify: function(evt) {
            var state = this.prevFirst === null ? 'init' : (this.prevFirst < this.first ? 'next' : 'prev');

            // Load items
            this.callback('itemLoadCallback', evt, state);

            if (this.prevFirst !== this.first) {
                this.callback('itemFirstInCallback', evt, state, this.first);
                this.callback('itemFirstOutCallback', evt, state, this.prevFirst);
            }

            if (this.prevLast !== this.last) {
                this.callback('itemLastInCallback', evt, state, this.last);
                this.callback('itemLastOutCallback', evt, state, this.prevLast);
            }

            this.callback('itemVisibleInCallback', evt, state, this.first, this.last, this.prevFirst, this.prevLast);
            this.callback('itemVisibleOutCallback', evt, state, this.prevFirst, this.prevLast, this.first, this.last);
        },

        callback: function(cb, evt, state, i1, i2, i3, i4) {
            if (this.options[cb] == null || (typeof this.options[cb] != 'object' && evt != 'onAfterAnimation')) {
                return;
            }

            var callback = typeof this.options[cb] == 'object' ? this.options[cb][evt] : this.options[cb];

            if (!$.isFunction(callback)) {
                return;
            }

            var self = this;

            if (i1 === undefined) {
                callback(self, state, evt);
            } else if (i2 === undefined) {
                this.get(i1).each(function() { callback(self, this, i1, state, evt); });
            } else {
                var call = function(i) {
                    self.get(i).each(function() { callback(self, this, i, state, evt); });
                };
                for (var i = i1; i <= i2; i++) {
                    if (i !== null && !(i >= i3 && i <= i4)) {
                        call(i);
                    }
                }
            }
        },

        create: function(i) {
            return this.format('<li></li>', i);
        },

        format: function(e, i) {
            e = $(e);
            var split = e.get(0).className.split(' ');
            for (var j = 0; j < split.length; j++) {
                if (split[j].indexOf('jcarousel-') != -1) {
                    e.removeClass(split[j]);
                }
            }
            e.addClass(this.className('jcarousel-item')).addClass(this.className('jcarousel-item-' + i)).css({
                'float': (this.options.rtl ? 'right' : 'left'),
                'list-style': 'none'
            }).attr('jcarouselindex', i);
            return e;
        },

        className: function(c) {
            return c + ' ' + c + (!this.options.vertical ? '-horizontal' : '-vertical');
        },

        dimension: function(e, d) {
            var el = e.jquery !== undefined ? e[0] : e;

            var old = !this.options.vertical ?
                (el.offsetWidth || $jc.intval(this.options.itemFallbackDimension)) + $jc.margin(el, 'marginLeft') + $jc.margin(el, 'marginRight') :
                (el.offsetHeight || $jc.intval(this.options.itemFallbackDimension)) + $jc.margin(el, 'marginTop') + $jc.margin(el, 'marginBottom');

            if (d == null || old == d) {
                return old;
            }

            var w = !this.options.vertical ?
                d - $jc.margin(el, 'marginLeft') - $jc.margin(el, 'marginRight') :
                d - $jc.margin(el, 'marginTop') - $jc.margin(el, 'marginBottom');

            $(el).css(this.wh, w + 'px');

            return this.dimension(el);
        },

        clipping: function() {
            return !this.options.vertical ?
                this.clip[0].offsetWidth - $jc.intval(this.clip.css('borderLeftWidth')) - $jc.intval(this.clip.css('borderRightWidth')) :
                this.clip[0].offsetHeight - $jc.intval(this.clip.css('borderTopWidth')) - $jc.intval(this.clip.css('borderBottomWidth'));
        },

        index: function(i, s) {
            if (s == null) {
                s = this.options.size;
            }

            return Math.round((((i-1) / s) - Math.floor((i-1) / s)) * s) + 1;
        }
    });

    $jc.extend({
        /**
         * Gets/Sets the global default configuration properties.
         *
         * @method defaults
         * @return {Object}
         * @param d {Object} A set of key/value pairs to set as configuration properties.
         */
        defaults: function(d) {
            return $.extend(defaults, d || {});
        },

        margin: function(e, p) {
            if (!e) {
                return 0;
            }

            var el = e.jquery !== undefined ? e[0] : e;

            if (p == 'marginRight' && $.browser.safari) {
                var old = {'display': 'block', 'float': 'none', 'width': 'auto'}, oWidth, oWidth2;

                $.swap(el, old, function() { oWidth = el.offsetWidth; });

                old.marginRight = 0;
                $.swap(el, old, function() { oWidth2 = el.offsetWidth; });

                return oWidth2 - oWidth;
            }

            return $jc.intval($.css(el, p));
        },

        intval: function(v) {
            v = parseInt(v, 10);
            return isNaN(v) ? 0 : v;
        }
    });

    /**
     * Creates a carousel for all matched elements.
     *
     * @example $("#mycarousel").jcarousel();
     * @before <ul id="mycarousel" class="jcarousel-skin-name"><li>First item</li><li>Second item</li></ul>
     * @result
     *
     * <div class="jcarousel-skin-name">
     *   <div class="jcarousel-container">
     *     <div class="jcarousel-clip">
     *       <ul class="jcarousel-list">
     *         <li class="jcarousel-item-1">First item</li>
     *         <li class="jcarousel-item-2">Second item</li>
     *       </ul>
     *     </div>
     *     <div disabled="disabled" class="jcarousel-prev jcarousel-prev-disabled"></div>
     *     <div class="jcarousel-next"></div>
     *   </div>
     * </div>
     *
     * @method jcarousel
     * @return jQuery
     * @param o {Hash|String} A set of key/value pairs to set as configuration properties or a method name to call on a formerly created instance.
     */
    $.fn.jcarousel = function(o) {
        if (typeof o == 'string') {
            var instance = $(this).data('jcarousel'), args = Array.prototype.slice.call(arguments, 1);
            return instance[o].apply(instance, args);
        } else {
            return this.each(function() {
                $(this).data('jcarousel', new $jc(this, o));
            });
        }
    };

})(jQuery);
/**
 * jGrowl 1.2.5
 *
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * Written by Stan Lemon <stosh1985@gmail.com>
 * Last updated: 2009.12.15
 *
 * jGrowl is a jQuery plugin implementing unobtrusive userland notifications.  These 
 * notifications function similarly to the Growl Framework available for
 * Mac OS X (http://growl.info).
 *
 * To Do:
 * - Move library settings to containers and allow them to be changed per container
 *
 * Changes in 1.2.5
 * - Changed wrapper jGrowl's options usage to "o" instead of $.jGrowl.defaults
 * - Added themeState option to control 'highlight' or 'error' for jQuery UI
 * - Ammended some CSS to provide default positioning for nested usage.
 * - Changed some CSS to be prefixed with jGrowl- to prevent namespacing issues
 * - Added two new options - openDuration and closeDuration to allow 
 *   better control of notification open and close speeds, respectively 
 *   Patch contributed by Jesse Vincet.
 * - Added afterOpen callback.  Patch contributed by Russel Branca.
 *
 * Changes in 1.2.4
 * - Fixed IE bug with the close-all button
 * - Fixed IE bug with the filter CSS attribute (special thanks to gotwic)
 * - Update IE opacity CSS
 * - Changed font sizes to use "em", and only set the base style
 *
 * Changes in 1.2.3
 * - The callbacks no longer use the container as context, instead they use the actual notification
 * - The callbacks now receive the container as a parameter after the options parameter
 * - beforeOpen and beforeClose now check the return value, if it's false - the notification does
 *   not continue.  The open callback will also halt execution if it returns false.
 * - Fixed bug where containers would get confused
 * - Expanded the pause functionality to pause an entire container.
 *
 * Changes in 1.2.2
 * - Notification can now be theme rolled for jQuery UI, special thanks to Jeff Chan!
 *
 * Changes in 1.2.1
 * - Fixed instance where the interval would fire the close method multiple times.
 * - Added CSS to hide from print media
 * - Fixed issue with closer button when div { position: relative } is set
 * - Fixed leaking issue with multiple containers.  Special thanks to Matthew Hanlon!
 *
 * Changes in 1.2.0
 * - Added message pooling to limit the number of messages appearing at a given time.
 * - Closing a notification is now bound to the notification object and triggered by the close button.
 *
 * Changes in 1.1.2
 * - Added iPhone styled example
 * - Fixed possible IE7 bug when determining if the ie6 class shoudl be applied.
 * - Added template for the close button, so that it's content could be customized.
 *
 * Changes in 1.1.1
 * - Fixed CSS styling bug for ie6 caused by a mispelling
 * - Changes height restriction on default notifications to min-height
 * - Added skinned examples using a variety of images
 * - Added the ability to customize the content of the [close all] box
 * - Added jTweet, an example of using jGrowl + Twitter
 *
 * Changes in 1.1.0
 * - Multiple container and instances.
 * - Standard $.jGrowl() now wraps $.fn.jGrowl() by first establishing a generic jGrowl container.
 * - Instance methods of a jGrowl container can be called by $.fn.jGrowl(methodName)
 * - Added glue preferenced, which allows notifications to be inserted before or after nodes in the container
 * - Added new log callback which is called before anything is done for the notification
 * - Corner's attribute are now applied on an individual notification basis.
 *
 * Changes in 1.0.4
 * - Various CSS fixes so that jGrowl renders correctly in IE6.
 *
 * Changes in 1.0.3
 * - Fixed bug with options persisting across notifications
 * - Fixed theme application bug
 * - Simplified some selectors and manipulations.
 * - Added beforeOpen and beforeClose callbacks
 * - Reorganized some lines of code to be more readable
 * - Removed unnecessary this.defaults context
 * - If corners plugin is present, it's now customizable.
 * - Customizable open animation.
 * - Customizable close animation.
 * - Customizable animation easing.
 * - Added customizable positioning (top-left, top-right, bottom-left, bottom-right, center)
 *
 * Changes in 1.0.2
 * - All CSS styling is now external.
 * - Added a theme parameter which specifies a secondary class for styling, such
 *   that notifications can be customized in appearance on a per message basis.
 * - Notification life span is now customizable on a per message basis.
 * - Added the ability to disable the global closer, enabled by default.
 * - Added callbacks for when a notification is opened or closed.
 * - Added callback for the global closer.
 * - Customizable animation speed.
 * - jGrowl now set itself up and tears itself down.
 *
 * Changes in 1.0.1:
 * - Removed dependency on metadata plugin in favor of .data()
 * - Namespaced all events
 */
(function($) {

	/** jGrowl Wrapper - Establish a base jGrowl Container for compatibility with older releases. **/
	$.jGrowl = function( m , o ) {
		// To maintain compatibility with older version that only supported one instance we'll create the base container.
		if ( $('#jGrowl').size() == 0 ) 
			$('<div id="jGrowl"></div>').addClass( (o && o.position) ? o.position : $.jGrowl.defaults.position ).appendTo('body');

		// Create a notification on the container.
		$('#jGrowl').jGrowl(m,o);
	};


	/** Raise jGrowl Notification on a jGrowl Container **/
	$.fn.jGrowl = function( m , o ) {
		if ( $.isFunction(this.each) ) {
			var args = arguments;

			return this.each(function() {
				var self = this;

				/** Create a jGrowl Instance on the Container if it does not exist **/
				if ( $(this).data('jGrowl.instance') == undefined ) {
					$(this).data('jGrowl.instance', $.extend( new $.fn.jGrowl(), { notifications: [], element: null, interval: null } ));
					$(this).data('jGrowl.instance').startup( this );
				}

				/** Optionally call jGrowl instance methods, or just raise a normal notification **/
				if ( $.isFunction($(this).data('jGrowl.instance')[m]) ) {
					$(this).data('jGrowl.instance')[m].apply( $(this).data('jGrowl.instance') , $.makeArray(args).slice(1) );
				} else {
					$(this).data('jGrowl.instance').create( m , o );
				}
			});
		};
	};

	$.extend( $.fn.jGrowl.prototype , {

		/** Default JGrowl Settings **/
		defaults: {
			pool: 			0,
			header: 		'',
			group: 			'',
			sticky: 		false,
			position: 		'bottom-left',
			glue: 			'after',
			theme: 			'default',
			themeState: 	'highlight',
			corners: 		'2px',
			check: 			250,
			life: 			15000,//Thoi gian hien thi 15s            
			closeDuration:  'normal',
			openDuration:   'normal',
			easing: 		'swing',
			closer: 		true,
			closeTemplate: '&times;',
			closerTemplate: '<div>[Đóng tất cả]</div>',
			log: 			function(e,m,o) {},
			beforeOpen: 	function(e,m,o) {},
			afterOpen: 		function(e,m,o) {},
			open: 			function(e,m,o) {},
			beforeClose: 	function(e,m,o) {},
			close: 			function(e,m,o) {},
			animateOpen: 	{
				opacity: 	'show'
			},
			animateClose: 	{
				opacity: 	'hide'
			}
		},
		
		notifications: [],
		
		/** jGrowl Container Node **/
		element: 	null,
	
		/** Interval Function **/
		interval:   null,
		
		/** Create a Notification **/
		create: 	function( message , o ) {
			var o = $.extend({}, this.defaults, o);

			/* To keep backward compatibility with 1.24 and earlier, honor 'speed' if the user has set it */
			if (typeof o.speed !== 'undefined') {
				o.openDuration = o.speed;
				o.closeDuration = o.speed;
			}

			this.notifications.push({ message: message , options: o });
			
			o.log.apply( this.element , [this.element,message,o] );
		},
		
		render: 		function( notification ) {
			var self = this;
			var message = notification.message;
			var o = notification.options;

			var notification = $(
				'<div class="jGrowl-notification ' + o.themeState + ' ui-corner-all' + 
				((o.group != undefined && o.group != '') ? ' ' + o.group : '') + '">' +
				'<div class="jGrowl-close">' + o.closeTemplate + '</div>' +
				'<div class="jGrowl-header">' + o.header + '</div>' +
				'<div class="jGrowl-message">' + message + '</div></div>'
			).data("jGrowl", o).addClass(o.theme).children('div.jGrowl-close').bind("click.jGrowl", function() {
				$(this).parent().trigger('jGrowl.close');
			}).parent();


			/** Notification Actions **/
			$(notification).bind("mouseover.jGrowl", function() {
				$('div.jGrowl-notification', self.element).data("jGrowl.pause", true);
			}).bind("mouseout.jGrowl", function() {
				$('div.jGrowl-notification', self.element).data("jGrowl.pause", false);
			}).bind('jGrowl.beforeOpen', function() {
				if ( o.beforeOpen.apply( notification , [notification,message,o,self.element] ) != false ) {
					$(this).trigger('jGrowl.open');
				}
			}).bind('jGrowl.open', function() {
				if ( o.open.apply( notification , [notification,message,o,self.element] ) != false ) {
					if ( o.glue == 'after' ) {
						$('div.jGrowl-notification:last', self.element).after(notification);
					} else {
						$('div.jGrowl-notification:first', self.element).before(notification);
					}
					
					$(this).animate(o.animateOpen, o.openDuration, o.easing, function() {
						// Fixes some anti-aliasing issues with IE filters.
						if ($.browser.msie && (parseInt($(this).css('opacity'), 10) === 1 || parseInt($(this).css('opacity'), 10) === 0))
							this.style.removeAttribute('filter');

						$(this).data("jGrowl").created = new Date();
						
						$(this).trigger('jGrowl.afterOpen');
					});
				}
			}).bind('jGrowl.afterOpen', function() {
				o.afterOpen.apply( notification , [notification,message,o,self.element] );
			}).bind('jGrowl.beforeClose', function() {
				if ( o.beforeClose.apply( notification , [notification,message,o,self.element] ) != false )
					$(this).trigger('jGrowl.close');
			}).bind('jGrowl.close', function() {
				// Pause the notification, lest during the course of animation another close event gets called.
				$(this).data('jGrowl.pause', true);
				$(this).animate(o.animateClose, o.closeDuration, o.easing, function() {
					$(this).remove();
					var close = o.close.apply( notification , [notification,message,o,self.element] );

					if ( $.isFunction(close) )
						close.apply( notification , [notification,message,o,self.element] );
				});
			}).trigger('jGrowl.beforeOpen');
		
			/** Optional Corners Plugin **/
			if ( o.corners != '' && $.fn.corner != undefined ) $(notification).corner( o.corners );

			/** Add a Global Closer if more than one notification exists **/
			if ( $('div.jGrowl-notification:parent', self.element).size() > 1 && 
				 $('div.jGrowl-closer', self.element).size() == 0 && this.defaults.closer != false ) {
				$(this.defaults.closerTemplate).addClass('jGrowl-closer ui-state-highlight ui-corner-all').addClass(this.defaults.theme)
					.appendTo(self.element).animate(this.defaults.animateOpen, this.defaults.speed, this.defaults.easing)
					.bind("click.jGrowl", function() {
						$(this).siblings().trigger("jGrowl.beforeClose");

						if ( $.isFunction( self.defaults.closer ) ) {
							self.defaults.closer.apply( $(this).parent()[0] , [$(this).parent()[0]] );
						}
					});
			};
		},

		/** Update the jGrowl Container, removing old jGrowl notifications **/
		update:	 function() {
			$(this.element).find('div.jGrowl-notification:parent').each( function() {
				if ( $(this).data("jGrowl") != undefined && $(this).data("jGrowl").created != undefined && 
					 ($(this).data("jGrowl").created.getTime() + parseInt($(this).data("jGrowl").life))  < (new Date()).getTime() && 
					 $(this).data("jGrowl").sticky != true && 
					 ($(this).data("jGrowl.pause") == undefined || $(this).data("jGrowl.pause") != true) ) {

					// Pause the notification, lest during the course of animation another close event gets called.
					$(this).trigger('jGrowl.beforeClose');
				}
			});

			if ( this.notifications.length > 0 && 
				 (this.defaults.pool == 0 || $(this.element).find('div.jGrowl-notification:parent').size() < this.defaults.pool) )
				this.render( this.notifications.shift() );

			if ( $(this.element).find('div.jGrowl-notification:parent').size() < 2 ) {
				$(this.element).find('div.jGrowl-closer').animate(this.defaults.animateClose, this.defaults.speed, this.defaults.easing, function() {
					$(this).remove();
				});
			}
		},

		/** Setup the jGrowl Notification Container **/
		startup:	function(e) {
			this.element = $(e).addClass('jGrowl').append('<div class="jGrowl-notification"></div>');
			this.interval = setInterval( function() { 
				$(e).data('jGrowl.instance').update(); 
			}, parseInt(this.defaults.check));
			
			if ($.browser.msie && parseInt($.browser.version) < 7 && !window["XMLHttpRequest"]) {
				$(this.element).addClass('ie6');
			}
		},

		/** Shutdown jGrowl, removing it and clearing the interval **/
		shutdown:   function() {
			$(this.element).removeClass('jGrowl').find('div.jGrowl-notification').remove();
			clearInterval( this.interval );
		},
		
		close: 	function() {
			$(this.element).find('div.jGrowl-notification').each(function(){
				$(this).trigger('jGrowl.beforeClose');
			});
		}
	});
	
	/** Reference the Defaults Object for compatibility with older versions of jGrowl **/
	$.jGrowl.defaults = $.fn.jGrowl.prototype.defaults;

})(jQuery);